jpillora / cloud-torrent

☁️ Cloud Torrent: a self-hosted remote torrent client
GNU Affero General Public License v3.0
5.79k stars 1.81k forks source link

Automatically add a systemd service to the bash script #321

Open Lyamc opened 3 years ago

Lyamc commented 3 years ago

A that would be needed is to add this to the script:

cat << SERVICE_CMD | sudo tee /etc/systemd/system/cloud-torrent.service
[Unit]
Description=Cloud Torrent System Daemon
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/cloud-torrent
StandardOutput=append:/var/log/cloud-torrent.log
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target
SERVICE_CMD

This will spit out a ready-to-use service that only needs the user to run:

sudo systemctl enable --now cloud-torrent

Uninstall would be simple:

sudo systemctl disable --now cloud-torrent
sudo rm -f /etc/systemd/system/cloud-torrent.service