예제 #1
0
def automation():
    print('''
##############################
##  Inside the "automation" folder you have a
##  bunch of Python scripts that can be added as
##  Cronjobs to automate some things
##  There is always an cronjob example inside the files if they
##  were built by the original developer
##  
##  Insite automation folder there is an example for an automated
##  command, carefully read the comments of that file as they
##  explain how to build an automation script and create a cronjob
##  for it, as they work seperatly from this program.
##
##  DO NOT FORGET TO EDIT THESE SCRIPTS FOR YOUR USE CASE/ OS
##############################''')
    try:
        back = int(input('input 0 to go back: '))
        if back == 0:
            from lib.category_menu import menu
            return menu()
        else:
            from lib.category_menu import menu
            print('Incorrect syntax')
            return automation()
    except:
        print('please input a ZERO to go back')
        from lib.category_menu import menu
        return menu()
def wireguard_check():
    os.system('sudo wg')
    print(
        'if you saw nothing but this you are not connected to your vpn server')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def ufw_basic():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES SUDO
##
##  This script installs UFW on the server
##  Creates a couple of default rules an then activates the firewall
##
##############################''')
    os.system('sudo apt install ufw -y')
    os.system('sudo ufw default deny incoming')
    os.system('sudo ufw default allow outgoing')
    os.system('sudo ufw allow ssh')
    os.system('sudo ufw enable')
    print('''
##############################
##  
##  UFW is now set up and installed, keep in mind that
##  YOU CAN ONLY RUN THIS SCRIPT ON SERVERS
##  Running it on a desktop will result in a loss of
##  internet connectivity!!
##
##############################''')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
예제 #4
0
def administration():
    print('''
##############################
##  0 -> Go back
##  1 -> Update system
##  2 -> Update hosts file
##  3 -> Install and setup ufw (SERVER ONLY)
##  4 -> Install cockpit
##  5 -> Install nginx
##  6 -> Edit sshd_config file
##############################''')
    question = input('''
##############################
##  What do you want to do? Chose a number:
##############################
INPUT: ''')
    try:
        response = int(question)
        if response == 0:
            response = 0
            from lib.category_menu import menu
            menu()
        elif response == 1:
            response = 0
            update()
        elif response == 2:
            response = 0
            hosts()
        elif response == 3:
            response = 0
            ufw_basic()
        elif response == 4:
            response = 0
            install_cockpit()
        elif response == 5:
            response = 0
            install_nginx()
        elif response == 6:
            response = 0
            sshd_config()
        else:
            print('error invalid choice')
    except:
        print('You need to chose a number')
예제 #5
0
def hosts():
    print('''
##############################
##
# opening /etc/hosts file, you need sudo rights!
##
# ''')
    subprocess.run(['sudo', 'nano', '/etc/hosts'])
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def update():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES SUDO
##
##############################''')
    os.system('sudo apt update')
    os.system('sudo apt upgrade -y')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def math():
    print('''
##############################
##  0 -> Go back
##  1 -> Find the square of a number
##############################''')
    question = input('''
##############################
##  What do you want to do? Chose a number:
##############################
INPUT: ''')
    try:
        response = int(question)
        if response == 0:
            response = 0
            from lib.category_menu import menu
            menu()
        elif response == 1:
            response = 0
            square()
        else:
            print('error invalid choice')
    except:
        print('You need to chose a number')
예제 #8
0
def monitoring():
    print('''
##############################
##  0 -> Go back
##  1 -> Watch GPU
##  2 -> top (all cores)
##  3 -> watch sensors
##  4 -> watch wireguard connection
##############################''')
    question = input('''
##############################
##  What do you want to do? Chose a number:
##############################
INPUT: ''')
    try:
        response = int(question)
        if response == 0:
            response = 0
            from lib.category_menu import menu
            menu()
        elif response == 1:
            response = 0
            watch_gpu()
        elif response == 2:
            response = 0
            top_all_cores()
        elif response == 3:
            response = 0
            watch_sensors()
        elif response == 4:
            response = 0
            wireguard_watch()
        else:
            print('error invalid choice')
    except:
        print('You need to chose a number')
def mining():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES NANOMINER INSTALLED ON THE SYSTEM
##
##    starting nanominer...
##    make sure your config.ini is in the root folder of the application
##    if you want monitoring windows open them before starting this script
##
##############################''')
    #   You have to use the ABSOLUTE PATH for your nanominer file
    #   DO NOT FORGET TO add a nanominer config file to the root folder of this program
    os.system('/home/filipe/Documents/nanominer-linux-3.1.2/nanominer')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def install_cockpit():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES SUDO
##
##  This script installs cockpit on the server
##  Enables and starts it
##  And adds port 9090 as an exception to UFW
##
##############################''')
    os.system('sudo apt install cockpit -y')
    os.system('sudo systemctl enable cockpit')
    os.system('sudo systemctl start cockpit')
    os.system('sudo ufw allow 9090/tcp comment "cockpit"')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def install_nginx():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES SUDO
##
##  This script installs NGINX on the server
##  Enables and starts it
##  And adds ports 80 and 443 as an exception to UFW
##
##############################''')
    os.system('sudo apt install nginx -y')
    os.system('sudo systemctl enable nginx')
    os.system('sudo systemctl start nginx')
    os.system('sudo ufw allow http')
    os.system('sudo ufw allow https')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
예제 #12
0
def sshd_config():
    print('''
##############################
##  
##    -> THIS SCRIPT REQUIRES SUDO
##
##  Opening sshd_config file
##
##############################''')
    os.system('sudo nano /etc/ssh/sshd_config')
    print('''
##############################
##
##  restarting sshd service to apply changes
##
##############################''')
    os.system('sudo systemctl restart sshd')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
예제 #13
0
def square():
    x = int(
        input('''
    ####################
    ####################
    ##
    ##  give me a number
    ##
    ####################
    ####################
    INPUT: '''))
    print('your number is ' + str(x))
    print('####################')
    y = x * x
    print('####################')
    print('the square of ' + str(x) + ' is ' + str(y))
    print('####################')
    print('####################')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
def add_alias():
    print('''
##############################
##
# This script adds armyknife alias to run this script in the end of the
# .bashrc file of the user that ran it
# IT ASSUMES YOU HAVE THE SCRIPT FOLDER IN YOUR HOME DIRECTORY
##
''')
    try:
        username = input(
            'What is the username on your system?: (case sensitive)')
        command = "echo alias armyknife='/home/{}/My-Linux-Swiss-Army-Knife-Script/myLinuxSwissArmyKnife.py' >> /home/{}/.bashrc".format(
            username, username)
        os.system(command)
    except:
        print('There was an error while trying to run this script!')
        return add_alias()

# required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
예제 #15
0
def wireguard_connect():
    os.system('sudo wg-quick up wg0')
    # required part for the script to return to the menu after running its job
    from lib.category_menu import menu
    return menu()
예제 #16
0
#!/usr/bin/env python3
from lib.category_menu import menu
print('''
##############################
##############################
##  Hello I am a simple python program developed as a way to learn it.
##  My main goal is to execute a number of functions and to spit out some output.
##############################
##############################
##  Please chose one of the following modules:
##############################''')
menu()