Ejemplo n.º 1
0
#!/usr/bin/env python
import nasmenu
from start_with_wol import wake_on_lan
from nasstop import shutdown_nas
from naspass import NasPass
import shelve

if __name__ == '__main__':
    nasmenu.print_greetings()
    user_input = nasmenu.print_menu("Main menu", nasmenu.main_menu_options)
    print(user_input)
    while int(user_input) <> 0:
        if int(user_input) == 1:
            s = shelve.open('config.dat')
            print("\nSending magic packet to MAC {}".format(s['mac']))
            wake_on_lan(s['mac'], s['broadcast'])
            s.close()
        elif int(user_input) == 2:
            print("Shutting down NAS!\n")
            s = shelve.open('config.dat')
            secret = NasPass()
            file = open("passwd.bin", "r")
            encrypted_pass = file.read()
            decrypted_pass = secret.decryptPassword(encrypted_pass)
            file.close()
            shutdown_nas(s['ip'], s['user'], decrypted_pass)
            s.close()
        elif int(user_input) == 3:
            execfile('nasconfigure.py')
        user_input = nasmenu.print_menu("Main menu", nasmenu.main_menu_options)
    if int(user_input) == 0:
Ejemplo n.º 2
0
        address = configure_address("NAS IP")
        s['ip'] = address
    elif int(choice) == 3:
        address = configure_address("broadcast")
        s['broadcast'] = address
    elif int(choice) == 4:
        s['user'] = configure_username()
        configure_password()
    elif int(choice) == 5:
        macaddress = configure_mac()
        nas_ip = configure_address("NAS IP")
        address = configure_address("broadcast")
        username = configure_username()
        configure_password()
        s['mac'] = macaddress
        s['ip'] = nas_ip
        s['broadcast'] = address
        s['user'] = username
    elif int(choice) == 6:
        print_current_setup()
    elif int(choice) == 0:
        execfile('nasmanager.py')
    s.close()

if __name__ == '__main__':
    initialize_shelf()
    choice = nasmenu.print_menu("Configuration menu", nasmenu.config_menu_options)
    while choice <> 0:
        change_configuration(choice)
        choice = nasmenu.print_menu("Configuration menu", nasmenu.config_menu_options)