Wire-Py/install.py
2024-09-15 02:09:43 +02:00

36 lines
903 B
Python
Executable File

#!/usr/bin/python3
from pathlib import Path
from getpass import getpass
# for services file in /lib/systemd/system/
config_path = Path.home() / ".config" / "wire_py" / "wg_py"
start_file = f'''\
#!/usr/bin/python3
from subprocess import check_call
from pathlib import Path
path_to_file = Path.home() / '.config/wire_py/wg_py'
if Path.exists(path_to_file):
a_con = Path.read_text(path_to_file)
check_call(['nmcli', 'connection', 'up', a_con])
else:
pass
'''
Path("start_wg.py").write_text(start_file)
config_path.parent.mkdir(exist_ok=True)
# Prompt the user for the sudo password
#sudo_password = getpass('Enter sudo password: ')
#def cp_files():
# Define the command to run the Python script with sudo
#command = ['sudo', '-S', 'python3', 'script.py']
# Run the command as a subprocess, passing the sudo password
#subprocess.run(command, input=sudo_password.encode(), check=True)