added to install script

This commit is contained in:
John Lancaster
2024-06-14 19:02:43 -05:00
parent 4ad717c341
commit ca7f62afe3

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import subprocess
from pathlib import Path from pathlib import Path
from rich import print from rich import print
@@ -20,8 +21,15 @@ def create_symlink(source, target):
print(f'Error creating symlink: {e}') print(f'Error creating symlink: {e}')
def run_command(command):
try:
subprocess.run(command, check=True, shell=True)
except subprocess.CalledProcessError as e:
print(f'Error running command: {command}\n{e}')
def main(): def main():
repo_dir = Path(__file__).resolve() repo_dir = Path(__file__).resolve().parent
systemd_dir = Path('/etc/systemd/system') systemd_dir = Path('/etc/systemd/system')
# Define the source and target paths # Define the source and target paths
@@ -32,6 +40,16 @@ def main():
create_symlink(repo_dir / socket_file, systemd_dir / socket_file) create_symlink(repo_dir / socket_file, systemd_dir / socket_file)
create_symlink(repo_dir / service_file, systemd_dir / service_file) create_symlink(repo_dir / service_file, systemd_dir / service_file)
# Reload systemd, start and enable the socket
run_command('sudo systemctl daemon-reload')
print('Reloaded systemd services')
run_command('sudo systemctl start example.socket')
print(f'Started [blue]{socket_file}[/]')
run_command('sudo systemctl enable example.socket')
print(f'Enabled [blue]{socket_file}[/] to start at boot')
if __name__ == '__main__': if __name__ == '__main__':
main() main()