From aa9dd11793ddf85b7c0da32393e4fa32ee697436 Mon Sep 17 00:00:00 2001 From: Cuan Date: Thu, 4 Nov 2021 23:02:59 -0400 Subject: [PATCH] Fixed bugs with config and syncing w/o files --- bin/sshync.py | 14 +++++++++----- bin/sshyp | 17 ++++++++--------- share/doc/sshyp/changelog | 7 ++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/bin/sshync.py b/bin/sshync.py index 0649b38..7e905a0 100755 --- a/bin/sshync.py +++ b/bin/sshync.py @@ -7,8 +7,6 @@ # TODO Add dry run support # TODO use partition command instead of split for separating paths # TODO use classes! -# Long-er Term Targets: -# TODO # sshync 2021.11.04.unreleased4 # sshync was created to solve a problem with rpass/sshyp, and as such, sshync will be bundled with sshyp until it is @@ -111,7 +109,10 @@ def time_sort(old_names, new_names, old_times): new_pos += 1 if title in old_names: old_pos = old_names.index(title) - remote_mod_times_new.append(old_times[old_pos]) + try: + remote_mod_times_new.append(old_times[old_pos]) + except IndexError: + pass return remote_mod_times_new @@ -139,8 +140,11 @@ def run_profile(profile_dir): '/var/lib/sshyp/sshyncdatabase_times') remote_mod_times = [] remote_mod_names, remote_mod_times_temp = get_file_paths_mod_remote('/var/lib/sshyp/sshyp.sshync') - for time in remote_mod_times_temp: # remove quotes from remote_mod_times - remote_mod_times.append(float(time)) + try: + for time in remote_mod_times_temp: # remove quotes from remote_mod_times + remote_mod_times.append(float(time)) + except ValueError: + pass lmod_short = [] rmod_short = [] matching_names = [] diff --git a/bin/sshyp b/bin/sshyp index ed66da6..454ec0e 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -139,13 +139,15 @@ if argument == 'show c': if argument == 'config': try: print() - devicetype = str(input('Will this be a client, server, or offline device? (C/s/o) ')) + devicetype = str(input('Will this be a client or a server device? (C/s) ')) if devicetype == 's' or devicetype == 'S': open("/var/lib/sshyp/sshyp-device", 'w').write(devicetype) print('\nMake sure the ssh service is running and properly configured.\n') copy('/usr/bin/sshync.py', '/home/' + environ.get('USER') + '/') + term('mkdir -p /home/' + environ.get('USER') + '/.password-pasture') print('Configuration complete!\n') else: + devicetype = 'c' gpgid = '' print() gpgpresent = str(input( @@ -172,11 +174,6 @@ if argument == 'config': pass term('gpg -r ' + str(gpgid) + ' -e ' + '/var/lib/sshyp/lock') remove('/var/lib/sshyp/lock') - if devicetype == 'o' or devicetype == 'O': - open("/var/lib/sshyp/sshyp-device", 'w').write(devicetype) - print('\nConfiguration complete!\n') - elif devicetype != 's' and devicetype != 'S': - devicetype = 'c' print('\nMake sure the ssh service on the remote server is running and properly configured.\n') sshgen = str(input('rsync support requires a unique ssh key. Would you like to have this ' 'automatically generated? (Y/n) ')) @@ -206,6 +203,7 @@ if argument == '': # import userdata +devicetype = 'c' try: devicetype = open('/var/lib/sshyp/sshyp-device').read().strip() gpgid = open('/var/lib/sshyp/sshyp-gpg').read().strip() @@ -217,9 +215,10 @@ try: directoryssh = sshinfo[4].replace('\n', '') term('mkdir -p ' + directory) except FileNotFoundError: - print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') - print("Not all necessary configuration files are present. Please run 'sshyp config'!") - print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') + if devicetype != 's' and devicetype != 'S': + print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') + print("Not all necessary configuration files are present. Please run 'sshyp config'!") + print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') devicetype, sshinfo, directory, directoryssh, ip, port, usernamessh = [0, 0, 0, 0, 0, 0, 0] exit() diff --git a/share/doc/sshyp/changelog b/share/doc/sshyp/changelog index b0a45f7..be09b2f 100644 --- a/share/doc/sshyp/changelog +++ b/share/doc/sshyp/changelog @@ -14,9 +14,14 @@ New features: Changes: - branding has been updated to reflect new project name and goals -- custom directories and ssh keys are removed (may be temporary) +- custom directories, custom ssh keys, and offline only mode are removed (may be temporary) - server installation makes copy of sshync.py in home directory +Bugs to fix!!:: +*error when syncing with no files in remote directory +*config warning not disappearing when using server config +*directory not generating with server config + Planned for next update (The Fluffy Update): - modularized and optimized code