|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# THIS SCRIPT DOESN'T WORK YET |
| 4 | + |
| 5 | +# install rtorrent, Node.JS |
| 6 | +curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - |
| 7 | +sudo apt update |
| 8 | +sudo apt install -y curl git rtorrent nodejs |
| 9 | + |
| 10 | +# .rtorrent.rc config file |
| 11 | +( |
| 12 | + echo "# Where rTorrent saves the downloaded files" |
| 13 | + echo "directory = /mnt/downloads/rtorrent/downloads" |
| 14 | + echo "" |
| 15 | + echo "# Where rTorrent saves the session" |
| 16 | + echo "session = /mnt/downloads/rtorrent/.session" |
| 17 | + echo "" |
| 18 | + echo "# Which ports rTorrent can use (Make sure to open them in your router)" |
| 19 | + echo "port_range = 50000-59999" |
| 20 | + echo "port_random = yes" |
| 21 | + echo "" |
| 22 | + echo "# Check the hash after the end of the download" |
| 23 | + echo "check_hash = yes" |
| 24 | + echo "" |
| 25 | + echo "# Enable DHT (for torrents without trackers)" |
| 26 | + echo "dht = auto" |
| 27 | + echo "dht_port = 6881" |
| 28 | + echo "peer_exchange = yes" |
| 29 | + echo "" |
| 30 | + echo "# Authorize UDP trackers" |
| 31 | + echo "use_udp_trackers = yes" |
| 32 | + echo "" |
| 33 | + echo "# Enable encryption when possible" |
| 34 | + echo "encryption = allow_incoming,try_outgoing,enable_retry" |
| 35 | + echo "" |
| 36 | + echo "# SCGI port, used to communicate with Flood" |
| 37 | + echo "scgi_port = 127.0.0.1:5000" |
| 38 | +) > ~/.rtorrent.rc |
| 39 | + |
| 40 | +# run rtorrent at boot |
| 41 | +( |
| 42 | + echo "[Unit]" |
| 43 | + echo "Description=rTorrent" |
| 44 | + echo "After=network.target" |
| 45 | + echo "" |
| 46 | + echo "[Service]" |
| 47 | + echo "Type=forking" |
| 48 | + echo "KillMode=none" |
| 49 | + echo "User=bismith" |
| 50 | + echo "WorkingDirectory=%h" |
| 51 | + echo "ExecStartPre=/bin/bash -c \"if test -e %h/.session/rtorrent.lock && test -z 'pidof rtorrent'; then rm -f %h/.session/rtorrent.lock; fi\"" |
| 52 | + echo "ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent" |
| 53 | + echo "ExecStop=/bin/bash -c \"test 'pidof rtorrent' && killall -w -s 2 /usr/bin/rtorrent\"" |
| 54 | + echo "Restart=on-failure" |
| 55 | + echo "" |
| 56 | + echo "[Install]" |
| 57 | + echo "WantedBy=multi-user.target" |
| 58 | +) | sudo tee /etc/systemd/system/rtorrent.service |
| 59 | +sudo systemctl enable rtorrent.service |
| 60 | +sudo systemctl start rtorrent.service |
| 61 | + |
| 62 | +# install flood |
| 63 | +cd ~ |
| 64 | +git clone https://github.com/jfurrow/flood.git |
| 65 | +cd flood |
| 66 | +cp config.template.js config.js |
| 67 | +npm install |
| 68 | +npm run build |
| 69 | + |
| 70 | +# run flood at boot |
| 71 | +( |
| 72 | + echo "[Service]" |
| 73 | + echo "WorkingDirectory=/home/$USER/flood" |
| 74 | + echo "ExecStart=/usr/bin/npm start" |
| 75 | + echo "Restart=always" |
| 76 | + echo "StandardOutput=syslog" |
| 77 | + echo "StandardError=syslog" |
| 78 | + echo "SyslogIdentifier=notell" |
| 79 | + echo "User=$USER" |
| 80 | + echo "Group=$USER" |
| 81 | + echo "Environment=NODE_ENV=production" |
| 82 | + echo "" |
| 83 | + echo "[Install]" |
| 84 | + echo "WantedBy=multi-user.target" |
| 85 | +) | sudo tee /etc/systemd/system/flood.service |
| 86 | +sudo systemctl enable flood.service |
| 87 | +sudo systemctl start flood.service |
0 commit comments