Skip to content

Instantly share code, notes, and snippets.

@thedward
Created December 9, 2015 04:25
Show Gist options
  • Save thedward/17e81cce83f56791f922 to your computer and use it in GitHub Desktop.
Save thedward/17e81cce83f56791f922 to your computer and use it in GitHub Desktop.
Per user transmission-daemon on Debian with systemd
#!/bin/bash
sudo apt-get install transmission-daemon
service_path=/lib/systemd/system/[email protected]
if ! [ -s "$service_path" ]
then
sudo tee "$service_path" <<-UNIT
[Unit]
Description=Transmission BitTorrent Daemon for %I
After=network.target
[Service]
User=%i
Type=notify
ExecStart=/usr/bin/transmission-daemon -f --log-error
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
UNIT
if ! [ -s /etc/sysctl.d/20-transmission.conf ]
then
sudo tee /etc/sysctl.d/20-transmission.conf <<-SYSCTL
net.core.wmem_max = 1048576
net.core.rmem_max = 4194304
SYSCTL
fi
else
printf >&2 'The unit file "%s" already exists.\n' "$service_path"
fi
cat >&2 <<-README
To activate a transmission for a particular user, enter the following commands:
sudo systemctl enable transmission-daemon@<user>.service
sudo systemctl start transmission-daemon@<user>.service
If you want to deactivate the default instance, enter these commands:
sudo systemctl stop transmission-daemon.service
sudo systemctl disable transmission-daemon.service
README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment