diff --git a/lib/sshyp.py b/lib/sshyp.py index 891f6fd..dc7fa40 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -295,7 +295,8 @@ this program comes with absolutely no warranty; type 'sshyp license' for details \u001b[1moptions:\u001b[0m help/-h{17*' '}bring up this menu version/-v{14*' '}display sshyp version info - settings{19*' '}configure sshyp + init{20*' '}set up sshyp + tweak{19*' '}change configuration options/manage extensions and updates add{21*' '}add an entry gen{21*' '}generate a new password edit{20*' '}edit an existing entry @@ -328,7 +329,7 @@ this program comes with absolutely no warranty; type 'sshyp license' for details \u001b[1moptions:\u001b[0m help/-h{17*' '}bring up this menu version/-v{14*' '}display sshyp version info - settings{19*' '}configure sshyp + init{20*' '}set up sshyp whitelist{15*' '}manage the quick-unlock whitelist \n\u001b[1mflags:\u001b[0m whitelist: @@ -706,7 +707,7 @@ if __name__ == "__main__": arg_count = len(arguments) # check if an entry name is correctly supplied - if arg_count < 1 or (arg_count > 0 and arguments[0] not in ('tweak', 'settings')): + if arg_count < 1 or (arg_count > 0 and arguments[0] != 'init'): if arg_count > 0 and arguments[0].startswith('/'): arg_start = 1 entry_name = arguments[0].strip('/') @@ -743,9 +744,9 @@ if __name__ == "__main__": else: ssh_error = True except (FileNotFoundError, IndexError): - print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') - print("not all necessary configurations have been made - please run 'sshyp settings'") - print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') + print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') + print("not all necessary configurations have been made - please run 'sshyp init'") + print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') s_exit(1) else: from stweak import initial_setup @@ -792,9 +793,13 @@ if __name__ == "__main__": success_flag, sync_flag = True, True remove_data() - elif arg_count == 1 and arg_start == 1: - success_flag = True - read_shortcut() + elif arg_count == 1: + if arg_start == 1: + success_flag = True + read_shortcut() + elif arguments[0] == 'tweak': + from stweak import global_menu + global_menu(False) # PORT START ARGS-SERVER # server arguments diff --git a/lib/stweak.py b/lib/stweak.py index 47e182e..9a45a06 100644 --- a/lib/stweak.py +++ b/lib/stweak.py @@ -161,8 +161,7 @@ def quick_unlock_config(_stdscr): return _enabled -# ARGUMENT-SPECIFIC FUNCTIONS -# runs configuration wizard +# runs initial configuration wizard def initial_setup(): # config directory creation Path(f"{home}/.config/sshyp/devices").mkdir(mode=0o700, parents=True, exist_ok=True) @@ -256,3 +255,25 @@ def initial_setup(): _lines += 1 _config_file.write('n') print('\nconfiguration complete\n') + + +# runs secondary configuration menu +def global_menu(_post_setup): + # curses initialization + _stdscr = initscr() + noecho() + cbreak() + _stdscr.keypad(True) + + # a client device is assumed, the server should never show this menu + _options = [] + if not _post_setup: + _options = ['change device/synchronization types', 'change gpg key', 're-configure ssh', 'change device name'] + _message = 'all configuration options' + _options.extend(['[OPTIONAL, RECOMMENDED] set custom text editor', + '[OPTIONAL, RECOMMENDED] enable/disable quick-unlock', + '[OPTIONAL, NOT IMPLEMENTED] su security mode', + '[OPTIONAL, NOT IMPLEMENTED] extensions and updates', 'exit']) + _message = 'additional configuration options' + + _choice = settings_radio(_stdscr, _options, _message)