Skip to content

Instantly share code, notes, and snippets.

@pandeykartikey
Created October 22, 2022 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandeykartikey/52e3559145409d184e49f7f75ba5cc6b to your computer and use it in GitHub Desktop.
Save pandeykartikey/52e3559145409d184e49f7f75ba5cc6b to your computer and use it in GitHub Desktop.
vps-transmission
### script.sh
sudo adduser "$USER"
sudo usermod -aG sudo "$USER"
su "$USER"
mkdir -p ~/.ssh
echo "###########################################################"
echo "Upload id_rsa.pub to ~/.ssh/authorized_keys and press ENTER"
echo "###########################################################"
read -rsn1 -p ""; echo
basic_setup() {
sudo apt update
sudo apt install apache2 aria2
}
transmission_setup() {
BASE_TRANSMISSION_DIR="/home/$USER/transmission";
SETTINGS_JSON_TEMPLATE="transmission/settings.json";
TRANSMISSION_CONFIG_TEMPLATE="transmission/transmission.conf";
DOWNLOADS_CONFIG_TEMPLATE="transmission/downloads.conf";
JELLYFIN_CONFIG_TEMPLATE="transmission/jellyfin.conf";
echo "#### Setting up transmission ####"
sudo add-apt-repository -y ppa:transmissionbt/ppa
sudo apt-get -y update
sudo apt-get install -y transmission-cli transmission-common transmission-daemon
sudo service transmission-daemon stop
sudo usermod -a -G debian-transmission "$USER"
mkdir -p "$BASE_TRANSMISSION_DIR/completed" "$BASE_TRANSMISSION_DIR/incomplete" "$BASE_TRANSMISSION_DIR/torrents";
sudo chgrp -R debian-transmission transmission
sudo chmod -R 775 transmission
read -p 'Enter transmission username: ' rpc_username;
read -sp 'Enter transmission password: ' rpc_password; echo;
sed -i "s/RPC_USER_REPLACE_STRING/$rpc_username/g" "$SETTINGS_JSON_TEMPLATE";
sed -i "s/RPC_PASS_REPLACE_STRING/$rpc_password/g" "$SETTINGS_JSON_TEMPLATE";
sed -i "s:BASE_TRANSMISSION_DIR_REPLACE_STRING:$BASE_TRANSMISSION_DIR:g" "$SETTINGS_JSON_TEMPLATE";
sudo cp -a /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings.json.default;
sudo cp "$SETTINGS_JSON_TEMPLATE" /etc/transmission-daemon/settings.json;
sudo service transmission-daemon start
sudo a2enmod proxy proxy_http proxy_http2 rewrite
sed -i "s/TRANSMISSION_URL/t.$DOMAIN/g" "$TRANSMISSION_CONFIG_TEMPLATE";
sudo cp "$TRANSMISSION_CONFIG_TEMPLATE" /etc/apache2/sites-available/transmission.conf;
sudo a2ensite transmission.conf
sudo service apache2 reload
sed -i "s/DOWNLOADS_URL/d.$DOMAIN/g" "$DOWNLOADS_CONFIG_TEMPLATE";
sed -i "s:TRANSMISSION_COMPLETED_PATH:$BASE_TRANSMISSION_DIR/completed:g" "$DOWNLOADS_CONFIG_TEMPLATE";
sudo cp "$DOWNLOADS_CONFIG_TEMPLATE" /etc/apache2/sites-available/downloads.conf;
sudo a2ensite downloads.conf
sudo service apache2 reload
sed -i "s/JELLYFIN_URL/j.$DOMAIN/g" "$JELLYFIN_CONFIG_TEMPLATE";
sudo cp "$JELLYFIN_CONFIG_TEMPLATE" /etc/apache2/sites-available/jellyfin.conf;
sudo a2enmod proxy proxy_http ssl proxy_wstunnel remoteip http2
sudo a2ensite jellyfin.conf
sudo service apache2 reload
}
basic_setup
transmission_setup
# SSL: https://certbot.eff.org/
# htpasswd: sudo htpasswd -c /etc/apache2/.htpasswd <username>
### htaccess
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
### Jellyfin vhost
<VirtualHost *:80>
ServerName JELLYFIN_URL
ProxyPreserveHost On
ProxyPass "/.well-known/" "!"
ProxyPass "/socket" "ws://127.0.0.1:8096/socket"
ProxyPassReverse "/socket" "ws://127.0.0.1:8096/socket"
ProxyPass "/" "http://127.0.0.1:8096/"
ProxyPassReverse "/" "http://127.0.0.1:8096/"
ErrorLog /var/log/apache2/jellyfin.error.log
CustomLog /var/log/apache2/jellyfin.access.log combined
</VirtualHost>
### transmission-settings.json
{
"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-dir": "BASE_TRANSMISSION_DIR_REPLACE_STRING/completed",
"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": "BASE_TRANSMISSION_DIR_REPLACE_STRING/incomplete",
"incomplete-dir-enabled": true,
"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": 0,
"ratio-limit-enabled": true,
"rename-partial-files": true,
"rpc-authentication-required": true,
"rpc-bind-address": "127.0.0.1",
"rpc-enabled": true,
"rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": true,
"rpc-password": "RPC_PASS_REPLACE_STRING",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "RPC_USER_REPLACE_STRING",
"rpc-whitelist": "127.0.0.1,*.*.*.*",
"rpc-whitelist-enabled": true,
"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": true,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 1,
"utp-enabled": true,
"watch-dir": "BASE_TRANSMISSION_DIR_REPLACE_STRING/torrents",
"watch-dir-enabled": true
}
### transmission vhost
<VirtualHost *:80>
ProxyPreserveHost On
ServerName TRANSMISSION_URL
ProxyPass / http://localhost:9091/
ProxyPassReverse / http://localhost:9091/
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment