|
|
|
@@ -8,11 +8,13 @@ from os import environ
|
|
|
|
|
from shutil import move
|
|
|
|
|
from shutil import rmtree
|
|
|
|
|
from sys import argv
|
|
|
|
|
from re import search
|
|
|
|
|
from re import escape
|
|
|
|
|
import random
|
|
|
|
|
import string
|
|
|
|
|
|
|
|
|
|
# custom modules
|
|
|
|
|
|
|
|
|
|
# custom modules
|
|
|
|
|
|
|
|
|
|
def clear():
|
|
|
|
|
print('\n' * 100)
|
|
|
|
@@ -22,12 +24,25 @@ def term(cmd):
|
|
|
|
|
_ = system(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def string_found(string1, string2):
|
|
|
|
|
if search(r"\b" + escape(string1) + r"\b", string2):
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def replace_line(file_name, line_num, text):
|
|
|
|
|
lines = open(file_name, 'r').readlines()
|
|
|
|
|
lines[line_num] = text
|
|
|
|
|
out = open(file_name, 'w')
|
|
|
|
|
out.writelines(lines)
|
|
|
|
|
out.close()
|
|
|
|
|
xlines = open(file_name, 'r').readlines()
|
|
|
|
|
xlines[line_num] = text
|
|
|
|
|
open(file_name, 'w').writelines(xlines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def edit_note():
|
|
|
|
|
lines = open('/dev/shm/' + shmfolder + '/' + shmentry).readlines()
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(lines[0:3])
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'w').writelines(lines[4:-2])
|
|
|
|
|
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
|
|
|
|
edit_notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n').read()
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'a').write('\n' + edit_notes + '\n\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shmgen():
|
|
|
|
@@ -101,8 +116,8 @@ if argument == 'version' or argument == '-v':
|
|
|
|
|
print('/ /')
|
|
|
|
|
print('/ rpass Copyright (C) 2021 Randall Winkhart /')
|
|
|
|
|
print('/ /')
|
|
|
|
|
print('/ Version 2021.09.15.mr4.1 /')
|
|
|
|
|
print('/ The Housekeeping Update (Pt. 1) /')
|
|
|
|
|
print('/ Version 2021.10.07.mr5 /')
|
|
|
|
|
print('/ The Notetaker Update /')
|
|
|
|
|
print('/ /')
|
|
|
|
|
print('////////////////////////////////////////////////////////\n')
|
|
|
|
|
|
|
|
|
@@ -130,27 +145,24 @@ if argument == 'config':
|
|
|
|
|
if directorychoice == 'n' or directorychoice == 'N':
|
|
|
|
|
print('\nFormat: /this/path/ends/with/a/slash/\n')
|
|
|
|
|
directory = str(input('Please input a custom directory: '))
|
|
|
|
|
with open("/var/lib/rpass/rpass-dir", 'w') as f:
|
|
|
|
|
f.write(directory + '\n')
|
|
|
|
|
open("/var/lib/rpass/rpass-dir", 'w').write(directory + '\n')
|
|
|
|
|
else:
|
|
|
|
|
with open("/var/lib/rpass/rpass-dir", 'w') as f:
|
|
|
|
|
f.write('/home/' + environ.get('USER') + '/.rpass-store/' + '\n')
|
|
|
|
|
open("/var/lib/rpass/rpass-dir", 'w').write('/home/' + environ.get('USER') + '/.rpass-store/' + '\n')
|
|
|
|
|
print()
|
|
|
|
|
devicetype = str(input('Will this be a client, server, or offline device? (C/s/o) '))
|
|
|
|
|
if devicetype == 's' or devicetype == 'S':
|
|
|
|
|
with open("/var/lib/rpass/rpass-ssh", 'w') as f:
|
|
|
|
|
f.write('\n\n\n\n' + devicetype)
|
|
|
|
|
open("/var/lib/rpass/rpass-ssh", 'w').write('\n\n\n\n' + devicetype)
|
|
|
|
|
print('\nMake sure the ssh service is running and properly configured.\n')
|
|
|
|
|
print('Configuration complete!\n')
|
|
|
|
|
else:
|
|
|
|
|
gpgid = ''
|
|
|
|
|
print()
|
|
|
|
|
gpgpresent = str(input(
|
|
|
|
|
'rpass requires the use of a unique gpg key. Do you already have one you are willing to use? (y/N) '))
|
|
|
|
|
if gpgpresent == 'y' or gpgpresent == 'Y':
|
|
|
|
|
print()
|
|
|
|
|
gpgid = str(input('Please input the ID of your gpg key: '))
|
|
|
|
|
with open("/var/lib/rpass/rpass-gpg", 'w') as f:
|
|
|
|
|
f.write(gpgid + '\n')
|
|
|
|
|
open("/var/lib/rpass/rpass-gpg", 'w').write(gpgid + '\n')
|
|
|
|
|
else:
|
|
|
|
|
print()
|
|
|
|
|
gpggen = str(
|
|
|
|
@@ -162,18 +174,23 @@ if argument == 'config':
|
|
|
|
|
term('gpg --full-generate-key')
|
|
|
|
|
print()
|
|
|
|
|
gpgid = str(input('Please input the ID of your gpg key: '))
|
|
|
|
|
with open("/var/lib/rpass/rpass-gpg", 'w') as f:
|
|
|
|
|
f.write(gpgid + '\n')
|
|
|
|
|
open("/var/lib/rpass/rpass-gpg", 'w').write(gpgid + '\n')
|
|
|
|
|
try:
|
|
|
|
|
open('/var/lib/rpass/lock', 'x').write('locked')
|
|
|
|
|
except FileExistsError:
|
|
|
|
|
pass
|
|
|
|
|
term('gpg -r ' + str(gpgid) + ' -e ' + '/var/lib/rpass/lock')
|
|
|
|
|
remove('/var/lib/rpass/lock')
|
|
|
|
|
if devicetype == 'o' or devicetype == 'O':
|
|
|
|
|
with open("/var/lib/rpass/rpass-ssh", 'w') as f:
|
|
|
|
|
f.write('\n\n\n\n' + devicetype)
|
|
|
|
|
open("/var/lib/rpass/rpass-ssh", 'w').write('\n\n\n\n' + 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) '))
|
|
|
|
|
if sshgen != 'n' and sshgen != 'N':
|
|
|
|
|
term('ssh-keygen -f ~/.ssh/rpass')
|
|
|
|
|
term('ssh-keygen -t ed25519 -f ~/.ssh/rpass')
|
|
|
|
|
print('\nExample input: 10.10.10.10:9999\n')
|
|
|
|
|
ip_port = str(input('What is the IP and ssh port of the remote server? '))
|
|
|
|
|
print()
|
|
|
|
@@ -186,14 +203,13 @@ if argument == 'config':
|
|
|
|
|
directoryssh = str(input('What directory is the server using?: '))
|
|
|
|
|
else:
|
|
|
|
|
directoryssh = ('/home/' + usernamessh + '/.rpass-store/')
|
|
|
|
|
with open("/var/lib/rpass/rpass-ssh", 'w') as f:
|
|
|
|
|
f.write(usernamessh + '\n' + ip + '\n' + port + '\n' + directoryssh + '\n' + devicetype)
|
|
|
|
|
open("/var/lib/rpass/rpass-ssh", 'w').write(usernamessh + '\n' + ip + '\n' + port + '\n' + directoryssh +
|
|
|
|
|
'\n' + devicetype)
|
|
|
|
|
print('\nConfiguration complete!\n')
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
print('\n\nConfiguration cancelled.\n')
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# startup help
|
|
|
|
|
|
|
|
|
|
if argument == '':
|
|
|
|
@@ -206,17 +222,16 @@ if argument == '':
|
|
|
|
|
try:
|
|
|
|
|
sshinfo = open("/var/lib/rpass/rpass-ssh").readlines()
|
|
|
|
|
usernamessh = sshinfo[0].replace('\n', '')
|
|
|
|
|
ip = (sshinfo[1].replace('\n', ''))
|
|
|
|
|
port = (sshinfo[2].replace('\n', ''))
|
|
|
|
|
directoryssh = (sshinfo[3].replace('\n', ''))
|
|
|
|
|
devicetype = (sshinfo[4].replace('\n', ''))
|
|
|
|
|
ip = sshinfo[1].replace('\n', '')
|
|
|
|
|
port = sshinfo[2].replace('\n', '')
|
|
|
|
|
directoryssh = sshinfo[3].replace('\n', '')
|
|
|
|
|
devicetype = sshinfo[4].replace('\n', '')
|
|
|
|
|
except (FileNotFoundError, IndexError):
|
|
|
|
|
usernamessh, ip, port, directoryssh, devicetype = (0, 0, 0, 0, 0)
|
|
|
|
|
directory = ''
|
|
|
|
|
try:
|
|
|
|
|
with open("/var/lib/rpass/rpass-gpg") as f:
|
|
|
|
|
gpgid = f.read().strip()
|
|
|
|
|
with open("/var/lib/rpass/rpass-dir") as f:
|
|
|
|
|
directory = f.read().strip()
|
|
|
|
|
gpgid = open("/var/lib/rpass/rpass-gpg").read().strip()
|
|
|
|
|
directory = open("/var/lib/rpass/rpass-dir").read().strip()
|
|
|
|
|
term('mkdir -p ' + directory)
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
|
|
@@ -262,28 +277,26 @@ if argument == 'add note' or argument == 'add -n':
|
|
|
|
|
try:
|
|
|
|
|
clear()
|
|
|
|
|
entryname = str(input('Name of note: '))
|
|
|
|
|
notes = str(input('Contents of note: '))
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
entryname, notes = (0, 0)
|
|
|
|
|
print('\n\nEntry add cancelled.\n')
|
|
|
|
|
exit()
|
|
|
|
|
shmfolder, shmentry = shmgen()
|
|
|
|
|
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
|
|
|
|
notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'r').read()
|
|
|
|
|
try:
|
|
|
|
|
if entryname.startswith('/'):
|
|
|
|
|
if entryname.replace('/', '', 1).__contains__('/'):
|
|
|
|
|
if entryname.startswith('/'): # check if user input contains slashes
|
|
|
|
|
if entryname.replace('/', '', 1).__contains__('/'): # create folder and entry if there are two slashes
|
|
|
|
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines('\n\n\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
|
|
|
|
encryptfolder()
|
|
|
|
|
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines('\n\n\n' + notes + '\n\n')
|
|
|
|
|
else: # create entry if there is only one slash
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines('\n\n\n' + notes + '\n\n')
|
|
|
|
|
else: # create entry if there are no slashes
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
@@ -300,28 +313,33 @@ if argument == 'add password' or argument == 'add -p':
|
|
|
|
|
username = str(input('Username: '))
|
|
|
|
|
password = str(input('Password: '))
|
|
|
|
|
url = str(input('URL: '))
|
|
|
|
|
notes = str(input('Additional notes: '))
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
entryname, username, password, url, notes = (0, 0, 0, 0, 0)
|
|
|
|
|
print('\n\nEntry add cancelled.\n')
|
|
|
|
|
exit()
|
|
|
|
|
shmfolder, shmentry = shmgen()
|
|
|
|
|
add_note = input('Add a note to this entry? (y/N) ')
|
|
|
|
|
if add_note == 'y' or add_note == 'Y':
|
|
|
|
|
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
|
|
|
|
notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'r').read()
|
|
|
|
|
else:
|
|
|
|
|
notes = ''
|
|
|
|
|
try:
|
|
|
|
|
if entryname.startswith('/'):
|
|
|
|
|
if entryname.replace('/', '', 1).__contains__('/'):
|
|
|
|
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + password + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
|
|
|
|
+ '\n\n' + notes + '\n\n')
|
|
|
|
|
encryptfolder()
|
|
|
|
|
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + password + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
|
|
|
|
+ '\n\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + password + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
|
|
|
|
+ '\n\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
@@ -504,7 +522,6 @@ if argument == 'edit note' or argument == 'edit -n':
|
|
|
|
|
term('cd ' + directory + '; ls -1 *')
|
|
|
|
|
print()
|
|
|
|
|
entryname = str(input('What file would you like to edit? '))
|
|
|
|
|
notes = str(input('New Note: '))
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
entryname, notes = (0, 0)
|
|
|
|
|
print('\n\nEdit cancelled.\n')
|
|
|
|
@@ -516,20 +533,20 @@ if argument == 'edit note' or argument == 'edit -n':
|
|
|
|
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
|
|
|
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
|
|
|
|
folder + '/' + folderentry + '.gpg')
|
|
|
|
|
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 3, notes + '\n')
|
|
|
|
|
edit_note()
|
|
|
|
|
remove(directory + folder + '/' + folderentry + '.gpg')
|
|
|
|
|
encryptfolder()
|
|
|
|
|
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
|
|
|
|
entryname.replace('/', '', 1) + '.gpg')
|
|
|
|
|
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 3, notes + '\n')
|
|
|
|
|
edit_note()
|
|
|
|
|
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
|
|
|
|
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 3, notes + '\n')
|
|
|
|
|
edit_note()
|
|
|
|
|
remove(directory + entryname + '.gpg')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
|
|
|
@@ -592,9 +609,9 @@ if argument == 'copy password' or argument == 'copy -p':
|
|
|
|
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
|
|
|
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
|
|
|
|
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
|
|
|
|
term('wl-copy ' + "'" + copyline[1].replace('\n', '') + "'")
|
|
|
|
|
term('wl-copy ' + "'" + copyline[1].replace('\n', '').replace("'", "'\\''") + "'")
|
|
|
|
|
else:
|
|
|
|
|
term('echo -n ' + "'" + copyline[1].replace('\n', '') + "'" + ' | xclip -sel c')
|
|
|
|
|
term('echo -n ' + "'" + copyline[1].replace('\n', '').replace("'", "'\\''") + "'" + ' | xclip -sel c')
|
|
|
|
|
rmtree('/dev/shm/' + shmfolder)
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
|
|
@@ -680,18 +697,18 @@ if argument == 'gen':
|
|
|
|
|
if entryname.startswith('/'):
|
|
|
|
|
if entryname.replace('/', '', 1).__contains__('/'):
|
|
|
|
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + passgen + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
|
|
|
|
+ '\n' + notes + '\n\n')
|
|
|
|
|
encryptfolder()
|
|
|
|
|
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + passgen + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
|
|
|
|
+ '\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
|
|
|
|
else:
|
|
|
|
|
with open('/dev/shm/' + shmfolder + '/' + shmentry, 'w') as f:
|
|
|
|
|
f.writelines(username + '\n' + passgen + '\n' + url + '\n' + notes + '\n\n')
|
|
|
|
|
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
|
|
|
|
+ '\n' + notes + '\n\n')
|
|
|
|
|
encrypt()
|
|
|
|
|
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
@@ -757,21 +774,28 @@ if argument == 'remove' or argument == '-rm':
|
|
|
|
|
print()
|
|
|
|
|
try:
|
|
|
|
|
entryname = str(input('What would you like to delete? '))
|
|
|
|
|
try:
|
|
|
|
|
term('gpg -d --output /dev/shm/rpass.lock /var/lib/rpass/lock.gpg')
|
|
|
|
|
unlocker = open('/dev/shm/rpass.lock', 'r').readlines()
|
|
|
|
|
remove('/dev/shm/rpass.lock')
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
print('\nAccess denied.\n')
|
|
|
|
|
exit()
|
|
|
|
|
if entryname.startswith('/'):
|
|
|
|
|
if entryname.replace('/', '', 1).__contains__('/'):
|
|
|
|
|
if devicetype == 'c' or devicetype == 'C':
|
|
|
|
|
term('ssh -p ' + port + '' + usernamessh + '@' + ip + ' rm -rf ' + "'" + directoryssh + "'" +
|
|
|
|
|
entryname.replace('/', '', 1) + '.gpg')
|
|
|
|
|
if devicetype == 'c':
|
|
|
|
|
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
|
|
|
|
entryname.replace('/', '', 1) + '.gpg' + "'" + '"')
|
|
|
|
|
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
|
|
|
|
else:
|
|
|
|
|
if devicetype == 'c' or devicetype == 'C':
|
|
|
|
|
term('ssh -p ' + port + '' + usernamessh + '@' + ip + ' rm -rf ' + "'" + directoryssh + "'" +
|
|
|
|
|
entryname.replace('/', '', 1))
|
|
|
|
|
if devicetype == 'c':
|
|
|
|
|
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
|
|
|
|
entryname.replace('/', '', 1) + "'" + '"')
|
|
|
|
|
rmtree(directory + entryname.replace('/', '', 1))
|
|
|
|
|
else:
|
|
|
|
|
if devicetype == 'c' or devicetype == 'C':
|
|
|
|
|
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' rm -rf ' + "'" + directoryssh + "'" +
|
|
|
|
|
entryname + '.gpg')
|
|
|
|
|
if devicetype == 'c':
|
|
|
|
|
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
|
|
|
|
entryname + '.gpg' + "'" + '"')
|
|
|
|
|
remove(directory + entryname + '.gpg')
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
print('\n\nDeletion cancelled.\n')
|
|
|
|
@@ -782,12 +806,12 @@ if argument == 'remove' or argument == '-rm':
|
|
|
|
|
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
if argument.__contains__('add') or argument.__contains__('-rm') or argument.__contains__('remove') or argument.\
|
|
|
|
|
__contains__('edit') or argument.__contains__('gen') or argument.__contains__('version') or argument.\
|
|
|
|
|
__contains__('-v') or argument.__contains__('config') or argument.__contains__('copy') or argument.\
|
|
|
|
|
__contains__('show') or argument.__contains__('/') or argument == 'sync' or argument == '-s' or argument == '' \
|
|
|
|
|
or argument == 'help' or argument == '--help' or argument == '-h':
|
|
|
|
|
null = 'null'
|
|
|
|
|
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
|
|
|
|
string_found('edit', argument) or string_found('gen', argument) or string_found('copy', argument) or \
|
|
|
|
|
string_found('/', argument) or argument == 'sync' or argument == '-s' or argument == '' or argument == 'help' \
|
|
|
|
|
or argument == '--help' or argument == '-h' or argument == 'version' or argument == '-v' or argument == \
|
|
|
|
|
'config' or argument == 'show w' or argument == 'show c':
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
print('\n!!!!!!!!!!!!!!!')
|
|
|
|
|
print('Argument error!')
|
|
|
|
@@ -800,11 +824,11 @@ term('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
|
|
|
|
term('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
|
|
|
|
|
|
|
|
|
# rsync - ran at end of program to ensure all files are properly synced
|
|
|
|
|
if devicetype == 'c' or devicetype == 'C':
|
|
|
|
|
if argument.__contains__('add') or argument.__contains__('-rm') or argument.__contains__('remove') or argument. \
|
|
|
|
|
__contains__('edit') or argument.__contains__('gen') or argument == 'sync' or argument == '-s':
|
|
|
|
|
if devicetype == 'c':
|
|
|
|
|
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
|
|
|
|
string_found('edit', argument) or string_found('gen', argument) or argument == 'sync' or argument == '-s':
|
|
|
|
|
print('Syncing entries with other device(s)...\n')
|
|
|
|
|
term('rsync -v -H -r -l -t -p -e ' + '"ssh -i ~/.ssh/rpass -p ' + port + '" ' + directory + ' ' + usernamessh
|
|
|
|
|
+ '@' + ip + ':' + directoryssh)
|
|
|
|
|
term('rsync -v -H -r -l -t -p -e ' + '"ssh -i ~/.ssh/rpass -p ' + port + '" ' + directory + ' ' +
|
|
|
|
|
usernamessh + '@' + ip + ':' + directoryssh)
|
|
|
|
|
term('rsync -v -H -r -l -t -p --delete -e ' + '"ssh -i ~/.ssh/rpass -p ' + port + '" ' + usernamessh
|
|
|
|
|
+ '@' + ip + ':' + directoryssh + ' ' + directory)
|
|
|
|
|