From b2cfa5d8f2418688a62f5adebc8eafd180d22e73 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 18 Apr 2023 14:30:58 -0400 Subject: [PATCH] port-jobs: Allow server tweak code to be removed by RMSERVER.py Former-commit-id: 788a356261f2bafbe66c1c7fa38204ba4f238cfa Former-commit-id: 7ee419cde8eb74ce7bd4e2b6e671ac081dabfffa --- lib/sshyp.py | 2 ++ port-jobs/RMSERVER.PY | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/sshyp.py b/lib/sshyp.py index 6392068..bb19422 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -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" diff --git a/port-jobs/RMSERVER.PY b/port-jobs/RMSERVER.PY index 1a133bf..4b8ea5f 100755 --- a/port-jobs/RMSERVER.PY +++ b/port-jobs/RMSERVER.PY @@ -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)