initial commit

This commit is contained in:
John Lancaster
2024-06-14 18:48:39 -05:00
commit 4ad717c341
4 changed files with 54 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.python-version
__pycache__

37
create_symlinks.py Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
from pathlib import Path
from rich import print
def create_symlink(source, target):
try:
target_path = Path(target)
# Check if the target already exists and remove it if it does
if target_path.exists() or target_path.is_symlink():
target_path.unlink()
# Create the symbolic link
target_path.symlink_to(source)
print(f'Created symlink: {source} -> {target}')
except OSError as e:
print(f'Error creating symlink: {e}')
def main():
repo_dir = Path(__file__).resolve()
systemd_dir = Path('/etc/systemd/system')
# Define the source and target paths
socket_file = 'example.socket'
service_file = 'example@.service'
# Create symlinks
create_symlink(repo_dir / socket_file, systemd_dir / socket_file)
create_symlink(repo_dir / service_file, systemd_dir / service_file)
if __name__ == '__main__':
main()

9
example.socket Normal file
View File

@@ -0,0 +1,9 @@
[Unit]
Description=Example Unix Socket
[Socket]
ListenStream=/run/example.sock
Accept=yes
[Install]
WantedBy=sockets.target

6
example@.service Normal file
View File

@@ -0,0 +1,6 @@
[Unit]
Description=Example Service
[Service]
ExecStart=/bin/bash -c 'echo "Hello, world!" > /tmp/example_output.txt'
StandardInput=socket