Skip to content

Instantly share code, notes, and snippets.

@raghavmri
Created August 27, 2025 03:39
Show Gist options
  • Select an option

  • Save raghavmri/79da32ff8daed7431bc9b99e167d8424 to your computer and use it in GitHub Desktop.

Select an option

Save raghavmri/79da32ff8daed7431bc9b99e167d8424 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
# === Variables ===
USERNAME="username" # Change this
RPC_PASSWORD="password123" # Change this
echo "📦 Installing Transmission..."
sudo apt-get update -y
sudo apt-get install -y transmission-daemon jq
echo "⏹ Stopping service..."
sudo systemctl stop transmission-daemon
# Temporary config file
TMPFILE=$(mktemp)
cat > "$TMPFILE" <<EOF
{
"download-dir": "/var/lib/transmission-daemon/downloads",
"rpc-authentication-required": true,
"rpc-bind-address": "0.0.0.0",
"rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": false,
"rpc-password": "$RPC_PASSWORD",
"rpc-port": 9091,
"rpc-username": "$USERNAME",
"rpc-whitelist": "*",
"rpc-whitelist-enabled": false,
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-limit": 100,
"download-limit-enabled": 0,
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/var/lib/transmission-daemon/Downloads",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"max-peers-global": 200,
"message-level": 1,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": false,
"preallocation": 1,
"prefetch-enabled": true,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-enabled": true,
"rpc-url": "/transmission/",
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 14,
"utp-enabled": true
}
EOF
# Compare and update if needed
if ! cmp -s "$TMPFILE" /etc/transmission-daemon/settings.json; then
echo "⚡ Updating settings.json..."
sudo cp /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings.json.bak.$(date +%s) 2>/dev/null || true
sudo cp "$TMPFILE" /etc/transmission-daemon/settings.json
sudo chown debian-transmission:debian-transmission /etc/transmission-daemon/settings.json
else
echo "✅ No changes needed in settings.json"
fi
rm -f "$TMPFILE"
echo "▶️ Starting Transmission..."
sudo systemctl start transmission-daemon
sudo systemctl enable transmission-daemon
echo "🚀 Transmission ready at: http://<server-ip>:9091/transmission"
echo " Username: $USERNAME"
echo " Password: $RPC_PASSWORD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment