mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 15:47:18 -04:00
Simplified expanduser statements
This commit is contained in:
@@ -49,7 +49,7 @@ def edit_note(_shm_folder, _shm_entry):
|
|||||||
def tweak(): # runs configuration wizard
|
def tweak(): # runs configuration wizard
|
||||||
# storage/config directory creation
|
# storage/config directory creation
|
||||||
try:
|
try:
|
||||||
mkdir(f"{path.expanduser('~')}/.password-pasture", 0o700)
|
mkdir(path.expanduser('~/.password-pasture'), 0o700)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
@@ -60,14 +60,14 @@ def tweak(): # runs configuration wizard
|
|||||||
# device type configuration
|
# device type configuration
|
||||||
_device_type = input('\nIs this installation for a client or for a server? (C/s) ')
|
_device_type = input('\nIs this installation for a client or for a server? (C/s) ')
|
||||||
if _device_type.lower() == 's':
|
if _device_type.lower() == 's':
|
||||||
open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device", 'w').write(_device_type)
|
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||||
copy('/usr/bin/sshync.py', path.expanduser('~/'))
|
copy('/usr/bin/sshync.py', path.expanduser('~/'))
|
||||||
print('\nMake sure the ssh service is running and properly configured.\n\nConfiguration complete!\n')
|
print('\nMake sure the ssh service is running and properly configured.\n\nConfiguration complete!\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
else:
|
else:
|
||||||
# device type configuration
|
# device type configuration
|
||||||
_device_type = 'c' # ensure device type flag is properly set
|
_device_type = 'c' # ensure device type flag is properly set
|
||||||
open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device", 'w').write(_device_type)
|
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||||
|
|
||||||
# gpg configuration
|
# gpg configuration
|
||||||
_gpg_id = input('\nsshyp requires the use of a unique gpg key. Do you already have one that you are '
|
_gpg_id = input('\nsshyp requires the use of a unique gpg key. Do you already have one that you are '
|
||||||
@@ -76,14 +76,14 @@ def tweak(): # runs configuration wizard
|
|||||||
print('\nA unique gpg key has been generated for you.')
|
print('\nA unique gpg key has been generated for you.')
|
||||||
system('gpg --full-generate-key')
|
system('gpg --full-generate-key')
|
||||||
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
||||||
open(f"{path.expanduser('~/.config/sshyp')}/sshyp-gpg", 'w').write(_gpg_id + '\n')
|
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
||||||
|
|
||||||
# lock file generation
|
# lock file generation
|
||||||
try:
|
try:
|
||||||
open(f"{path.expanduser('~/.config/sshyp')}/lock", 'x').write('')
|
open(path.expanduser('~/.config/sshyp/lock'), 'x').write('')
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
system(f"gpg -r {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp')}/lock")
|
system(f"gpg -r {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp/lock')}")
|
||||||
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
||||||
|
|
||||||
# ssh key configuration
|
# ssh key configuration
|
||||||
@@ -93,7 +93,7 @@ def tweak(): # runs configuration wizard
|
|||||||
if _ssh_gen.lower() != 'n':
|
if _ssh_gen.lower() != 'n':
|
||||||
system('ssh-keygen -t ed25519 -f ~/.ssh/sshyp')
|
system('ssh-keygen -t ed25519 -f ~/.ssh/sshyp')
|
||||||
else:
|
else:
|
||||||
print(f"\nEnsure that the key file you are using is located at {path.expanduser('~')}/.ssh/sshyp")
|
print(f"\nEnsure that the key file you are using is located at {path.expanduser('~/.ssh/sshyp')}")
|
||||||
|
|
||||||
# ssh ip+port configuration
|
# ssh ip+port configuration
|
||||||
print('\nExample input: 10.10.10.10:9999\n')
|
print('\nExample input: 10.10.10.10:9999\n')
|
||||||
@@ -105,9 +105,9 @@ def tweak(): # runs configuration wizard
|
|||||||
print(f"\nEntry directory: /home/{_username_ssh}/.password-pasture/")
|
print(f"\nEntry directory: /home/{_username_ssh}/.password-pasture/")
|
||||||
|
|
||||||
# sshync profile generation
|
# sshync profile generation
|
||||||
sshync.make_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync",
|
sshync.make_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'),
|
||||||
f"{path.expanduser('~')}/.password-pasture/", f"/home/{_username_ssh}/.password-pasture/",
|
path.expanduser('~/.password-pasture/'), f"/home/{_username_ssh}/.password-pasture/",
|
||||||
f"{path.expanduser('~')}/.ssh/sshyp", _ip, _port, _username_ssh)
|
path.expanduser('~/.ssh/sshyp'), _ip, _port, _username_ssh)
|
||||||
print('\nConfiguration complete!\n')
|
print('\nConfiguration complete!\n')
|
||||||
|
|
||||||
|
|
||||||
@@ -152,8 +152,8 @@ def print_info(): # prints help text based on argument
|
|||||||
print('/ /')
|
print('/ /')
|
||||||
print('/ sshyp Copyright (C) 2021 Randall Winkhart /')
|
print('/ sshyp Copyright (C) 2021 Randall Winkhart /')
|
||||||
print('/ /')
|
print('/ /')
|
||||||
print('/ Version 2022.01.13.fr3 /')
|
print('/ Version 2022.01.13.fr3.1 /')
|
||||||
print('/ The Boxing Update /')
|
print('/ The Boxing Update /')
|
||||||
print('/ /')
|
print('/ /')
|
||||||
print('////////////////////////////////////////////////////////\n')
|
print('////////////////////////////////////////////////////////\n')
|
||||||
elif argument == 'license':
|
elif argument == 'license':
|
||||||
@@ -206,7 +206,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
# set permissions before uploading
|
# set permissions before uploading
|
||||||
system('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
system('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
||||||
system('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
system('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
||||||
sshync.run_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync")
|
sshync.run_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'))
|
||||||
|
|
||||||
|
|
||||||
def add_entry(): # adds a new entry
|
def add_entry(): # adds a new entry
|
||||||
@@ -381,7 +381,7 @@ def remove_data(): # deletes an entry or folder from both the client and the se
|
|||||||
if _entry_name.startswith('/'):
|
if _entry_name.startswith('/'):
|
||||||
_entry_name = _entry_name.replace('/', '', 1)
|
_entry_name = _entry_name.replace('/', '', 1)
|
||||||
try:
|
try:
|
||||||
system(f"gpg -d --output /dev/shm/sshyp.lock {path.expanduser('~/.config/sshyp')}/lock.gpg")
|
system(f"gpg -d --output /dev/shm/sshyp.lock {path.expanduser('~/.config/sshyp/lock.gpg')}")
|
||||||
_unlock = open('/dev/shm/sshyp.lock', 'r').readlines()
|
_unlock = open('/dev/shm/sshyp.lock', 'r').readlines()
|
||||||
remove('/dev/shm/sshyp.lock')
|
remove('/dev/shm/sshyp.lock')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@@ -407,10 +407,10 @@ argument = argument[:-1]
|
|||||||
if argument != 'tweak':
|
if argument != 'tweak':
|
||||||
device_type = ''
|
device_type = ''
|
||||||
try:
|
try:
|
||||||
device_type = open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device").read().strip()
|
device_type = open(path.expanduser('~/.config/sshyp/sshyp-device')).read().strip()
|
||||||
if device_type == 'c':
|
if device_type == 'c':
|
||||||
gpg_id = open(f"{path.expanduser('~/.config/sshyp')}/sshyp-gpg").read().strip()
|
gpg_id = open(path.expanduser('~/.config/sshyp/sshyp-gpg')).read().strip()
|
||||||
ssh_info = sshync.get_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync")
|
ssh_info = sshync.get_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'))
|
||||||
username_ssh = ssh_info[0].replace('\n', '')
|
username_ssh = ssh_info[0].replace('\n', '')
|
||||||
ip = ssh_info[1].replace('\n', '')
|
ip = ssh_info[1].replace('\n', '')
|
||||||
port = ssh_info[2].replace('\n', '')
|
port = ssh_info[2].replace('\n', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user