Make installation user-specific

This commit is contained in:
PAlexanderFranklin 2024-08-01 17:46:39 -07:00
parent b94d8ffeb6
commit d9d6cbeec5
2 changed files with 20 additions and 10 deletions

View File

@ -1,18 +1,28 @@
#!/bin/bash
# Install Python dependencies
pip3 install -r requirements.txt
pip3 install --user -r requirements.txt
# Create necessary directories
mkdir -p ~/.screenmonitor/script
mkdir -p ~/.screenmonitor/output
# Copy Python script to the install location
cp src/screenmonitor.py ~/.screenmonitor/script/
# Create user-specific systemd directory
mkdir -p ~/.config/systemd/user/
# Copy the systemd service file
sudo cp src/screenmonitor.service /etc/systemd/system/
cp src/screenmonitor.service ~/.config/systemd/user/screenmonitor.service
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
systemctl --user daemon-reload
# Enable the service to start on boot
sudo systemctl enable screenmonitor
systemctl --user enable screenmonitor
# Start the service
sudo systemctl start screenmonitor
systemctl --user start screenmonitor
echo "Service installed and started successfully."
echo "Service installed and started successfully for user $USER."

View File

@ -1,11 +1,11 @@
[Unit]
Description=My Custom Service
Description=Screen Monitor Service
After=network.target
[Service]
ExecStart=/usr/bin/python3 /path/to/my_service/src/script.py
ExecStart=/usr/bin/python3 /home/%u/.screenmonitor/script/screenmonitor.py
Restart=always
User=your_user
User=%u
[Install]
WantedBy=multi-user.target
WantedBy=default.target