├── .rtorrent.rc ├── README.md └── rtorrent /.rtorrent.rc: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # ~/.rtorrent.rc 3 | # 4 | # rtorrent configuration 5 | # ____ _ _ 6 | # / ___| ___ ___ __| | |__ _____ __ 7 | # \___ \ / _ \/ _ \/ _` | '_ \ / _ \ \/ / 8 | # ___) | __/ __/ (_| | |_) | (_) > < 9 | # |____/ \___|\___|\__,_|_.__/ \___/_/\_\ 10 | # 11 | # @see http://torrent-invites.com/help/172374-advice-rtorrent-rc-config.html 12 | # ---------------------------------------------------------------------- 13 | 14 | # ---------------------------------------------------------------------- 15 | # BitTorrent 16 | # ---------------------------------------------------------------------- 17 | 18 | max_downloads_global = 0 19 | max_uploads_global = 0 20 | min_peers = 500 21 | max_peers = 1000 22 | min_peers_seed = 500 23 | max_peers_seed = 1000 24 | max_uploads = 1000 25 | download_rate = 0 26 | upload_rate = 0 27 | tracker_numwant = 250 28 | 29 | # ---------------------------------------------------------------------- 30 | # Directories 31 | # ---------------------------------------------------------------------- 32 | 33 | directory = /home/killjoy/rtorrent 34 | session = /home/killjoy/.session 35 | schedule = watch_directory,5,5,load_start=/home/killjoy/torrents/*.torrent 36 | encoding_list = UTF-8 37 | 38 | # ---------------------------------------------------------------------- 39 | # Network 40 | # ---------------------------------------------------------------------- 41 | 42 | port_range = 51777-51780 43 | scgi_local = /var/run/rtorrent/rpc.socket 44 | network.http.ssl_verify_peer.set = 0 45 | port_random = yes 46 | use_udp_trackers = yes 47 | encryption = allow_incoming,enable_retry,prefer_plaintext 48 | network.max_open_files.set = 65536 49 | network.max_open_sockets.set = 1536 50 | network.http.max_open.set = 48 51 | network.send_buffer.size.set = 4M 52 | network.receive_buffer.size.set = 4M 53 | network.xmlrpc.size_limit.set = 4M 54 | dht = auto 55 | dht_port = 6881 56 | peer_exchange = yes 57 | 58 | # ---------------------------------------------------------------------- 59 | # Hash 60 | # ---------------------------------------------------------------------- 61 | 62 | check_hash = no 63 | pieces.preload.type.set = 1 64 | max_memory_usage = 5000M -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Init script for rtorrent + screen for Debian 2 | 3 | A simple init.d script for Debian based systems to start rtorrent in the background using screen. The script is based on [Greg Methvin's great init.d script](http://methvin.net/scripts/rtorrent). The difference here is that this init script is specifically designed for the usage of rtorrent together with rutorrent. It will ensure that the socket that is used by rtorrent for the XMLRPC connection gets deleted before attempting to start rtorrent or when stopping rtorrent. 4 | 5 | Feel free to contact me and help extending the script to make it more awesome! 6 | -------------------------------------------------------------------------------- /rtorrent: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: rtorrent 4 | # Required-Start: $local_fs $remote_fs $network $syslog 5 | # Required-Stop: $local_fs $remote_fs $network $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Start/stop rtorrent daemon 9 | ### END INIT INFO 10 | 11 | # ------------------------------------------------------------------------------ 12 | # /etc/init.d/rtorrent 13 | # 14 | # This script is an init script to run rtorrent in the background, using a 15 | # screen. The script was designed and tested for Debian systems, but may work on 16 | # other systems. On Debian, enable it by moving the script to 17 | # "/etc/init.d/rtorrent" and issuing the command 18 | # "update-rc.d rtorrent defaults 99" 19 | # ____ _ _ 20 | # / ___| ___ ___ __| | |__ _____ __ 21 | # \___ \ / _ \/ _ \/ _` | '_ \ / _ \ \/ / 22 | # ___) | __/ __/ (_| | |_) | (_) > < 23 | # |____/ \___|\___|\__,_|_.__/ \___/_/\_\ 24 | # 25 | # @see http://methvin.net/scripts/rtorrent 26 | # @see http://tldp.org/LDP/abs/html/ 27 | # ------------------------------------------------------------------------------ 28 | 29 | ## Username to run rtorrent under, make sure you have a .rtorrent.rc in the 30 | ## home directory of this user! 31 | USER="killjoy" 32 | 33 | ## Absolute path to the rtorrent binary. 34 | RTORRENT="/usr/bin/rtorrent" 35 | 36 | ## Absolute path to the screen binary. 37 | SCREEN="/usr/bin/screen" 38 | 39 | ## Name of the screen session, you can then "screen -r rtorrent" to get it back 40 | ## to the forground and work with it on your shell. 41 | SCREEN_NAME="rtorrent" 42 | 43 | ## Absolute path to rtorrent's PID file. 44 | PIDFILE="/var/run/rtorrent.pid" 45 | 46 | ## Absolute path to rtorrent's XMLRPC socket. 47 | SOCKET="/var/run/rtorrent/rpc.socket" 48 | 49 | ## Check if the socket exists and if it exists delete it. 50 | delete_socket() { 51 | if [[ -e $SOCKET ]]; then 52 | rm -f $SOCKET 53 | fi 54 | } 55 | 56 | case "$1" in 57 | ## Start rtorrent in the background. 58 | start) 59 | echo "Starting rtorrent." 60 | delete_socket 61 | start-stop-daemon --start --background --oknodo \ 62 | --pidfile "$PIDFILE" --make-pidfile \ 63 | --chuid $USER \ 64 | --exec $SCREEN -- -DmUS $SCREEN_NAME $RTORRENT 65 | if [[ $? -ne 0 ]]; then 66 | echo "Error: rtorrent failed to start." 67 | exit 1 68 | fi 69 | echo "rtorrent started successfully." 70 | ;; 71 | 72 | ## Stop rtorrent. 73 | stop) 74 | echo "Stopping rtorrent." 75 | start-stop-daemon --stop --oknodo --pidfile "$PIDFILE" 76 | if [[ $? -ne 0 ]]; then 77 | echo "Error: failed to stop rtorrent process." 78 | exit 1 79 | fi 80 | delete_socket 81 | echo "rtorrent stopped successfully." 82 | ;; 83 | 84 | ## Restart rtorrent. 85 | restart) 86 | "$0" stop 87 | sleep 1 88 | "$0" start || exit 1 89 | ;; 90 | 91 | ## Print usage information if the user gives an invalid option. 92 | *) 93 | echo "Usage: $0 [start|stop|restart]" 94 | exit 1 95 | ;; 96 | 97 | esac 98 | --------------------------------------------------------------------------------