Make installation user-specific
This commit is contained in:
parent
b94d8ffeb6
commit
d9d6cbeec5
22
install.sh
22
install.sh
@ -1,18 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Install Python dependencies
|
# 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
|
# 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
|
# Reload systemd to recognize the new service
|
||||||
sudo systemctl daemon-reload
|
systemctl --user daemon-reload
|
||||||
|
|
||||||
# Enable the service to start on boot
|
# Enable the service to start on boot
|
||||||
sudo systemctl enable screenmonitor
|
systemctl --user enable screenmonitor
|
||||||
|
|
||||||
# Start the service
|
# 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."
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=My Custom Service
|
Description=Screen Monitor Service
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/python3 /path/to/my_service/src/script.py
|
ExecStart=/usr/bin/python3 /home/%u/.screenmonitor/script/screenmonitor.py
|
||||||
Restart=always
|
Restart=always
|
||||||
User=your_user
|
User=%u
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
|
Loading…
Reference in New Issue
Block a user