mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-30 22:06:28 -04:00
Former-commit-id: 640dd6a448fc9df35a20ec253e1498b142a47a04 Former-commit-id: e66d00a8bce55319c9310835b1d2963531ca34ca
48 lines
1.3 KiB
Python
Executable File
48 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import re
|
|
from sys import argv, exit as s_exit
|
|
|
|
# read arguments
|
|
arguments = argv[1:]
|
|
|
|
# define replacement text depending on arguments
|
|
if len(arguments) > 0:
|
|
if arguments[0] == 'TMP':
|
|
replacement = 'symlink("/tmp", f"{home}/.config/sshyp/tmp")'
|
|
elif arguments[0] == 'TERMUX':
|
|
replacement = 'symlink("/data/data/com.termux/files/usr/tmp", f"{home}/.config/sshyp/tmp")'
|
|
elif arguments[0] == 'LINUX':
|
|
replacement = 'symlink("/dev/shm", f"{home}/.config/sshyp/tmp")'
|
|
else:
|
|
s_exit()
|
|
|
|
# UNAME-IMPORT
|
|
# define PORT target
|
|
string1 = '# PORT START UNAME-IMPORT'
|
|
string2 = '# PORT END UNAME-IMPORT'
|
|
|
|
# read input file
|
|
text = open('working/sshyp.py', 'r').read()
|
|
|
|
# find and replace the defined PORT target
|
|
regex = re.compile(f"{string1}.*?{string2}\n", re.DOTALL)
|
|
new_text = re.sub(regex, '', text)
|
|
|
|
# write updated text
|
|
open('working/sshyp.py', 'w').write(new_text)
|
|
|
|
# UNAME-TMP
|
|
# define PORT target
|
|
string1 = '# PORT START UNAME-TMP'
|
|
string2 = '# PORT END UNAME-TMP'
|
|
|
|
# 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)
|