port-jobs: Allow server tweak code to be removed by RMSERVER.py

Former-commit-id: 788a356261f2bafbe66c1c7fa38204ba4f238cfa
Former-commit-id: 7ee419cde8eb74ce7bd4e2b6e671ac081dabfffa
This commit is contained in:
2023-04-18 14:30:58 -04:00
parent 98a10cc0cf
commit b2cfa5d8f2
2 changed files with 22 additions and 0 deletions
+2
View File
@@ -221,6 +221,7 @@ def tweak():
else:
symlink('/dev/shm', f"{home}/.config/sshyp/tmp")
# PORT START TWEAK-DEVTYPE
# device type configuration
_device_type = input('\nclient or server installation? (C/s) ')
if _device_type.lower() == 's':
@@ -231,6 +232,7 @@ def tweak():
else:
_sshyp_data = ['client']
Path(f"{home}/.local/share/sshyp").mkdir(mode=0o700, parents=True, exist_ok=True)
# PORT END TWEAK-DEVTYPE
# gpg configuration
_gpg_gen = input(f"{_divider}sshyp requires the use of a unique gpg key - use an (e)xisting key or (g)enerate a"
+20
View File
@@ -31,3 +31,23 @@ new_text = re.sub(regex, '', text)
# write updated text
open('working/sshyp.py', 'w').write(new_text)
# TWEAK-DEVTYPE
# define PORT target
string1 = '# PORT START TWEAK-DEVTYPE'
string2 = '# PORT END TWEAK-DEVTYPE'
# set replacement text
replacement = """if True:
_sshyp_data = ['client']
Path(f"{home}/.local/share/sshyp").mkdir(mode=0o700, parents=True, exist_ok=True)"""
# read input file
text = open('working/sshyp.py', 'r').read()
# find and replace the defined PORT target
regex = re.compile(f"{string1}.*?{string2}", re.DOTALL)
new_text = re.sub(regex, replacement, text)
# write updated text
open('working/sshyp.py', 'w').write(new_text)