├── .travis.yml ├── Makefile ├── README.md ├── alpine.sh ├── arch.sh ├── files ├── armhf │ └── mod_scgi.so ├── x86 │ └── mod_scgi.so └── x86_64 │ └── mod_scgi.so ├── include.sh ├── plugins.sh └── ubuntu-debian.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | script: sh -n *.sh 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | OPTION= 2 | 3 | help: 4 | @echo "OPTIONS:" 5 | @echo "sudo make install alpine" 6 | @echo "sudo make uninstall alpine" 7 | @echo "sudo make install arch" 8 | @echo "sudo make uninstall arch" 9 | @echo "sudo make install debian" 10 | @echo "sudo make uninstall debian" 11 | @echo "sudo make install ubuntu" 12 | @echo "sudo make uninstall ubuntu" 13 | 14 | install: 15 | $(eval OPTION="install") 16 | 17 | uninstall: 18 | $(eval OPTION="uninstall") 19 | 20 | alpine: 21 | ./alpine.sh $(OPTION) 22 | 23 | arch: 24 | ./arch.sh $(OPTION) 25 | 26 | debian: 27 | ./ubuntu-debian.sh $(OPTION) 28 | 29 | ubuntu: 30 | ./ubuntu-debian.sh $(OPTION) 31 | 32 | .PHONY: install uninstall alpine arch debian ubuntu 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rTorrent + libTorrent + ruTorrent + Webserver + XMLRPC-C (un)installation script 2 | [![Build Status](https://travis-ci.org/dawidd6/seedbox.svg?branch=master)](https://travis-ci.org/dawidd6/seedbox) 3 | 4 | ### Usage 5 | One can use make to easily open right script: 6 | ```sh 7 | git clone https://github.com/dawidd6/seedbox.git ~/seedbox 8 | cd ~/seedbox 9 | make 10 | ``` 11 | When you type `make` you will get possible commands 12 | 13 | 14 | Or one can open desired script manually: 15 | ```sh 16 | git clone https://github.com/dawidd6/seedbox.git ~/seedbox 17 | cd ~/seedbox 18 | sudo ./"script" install 19 | #or 20 | sudo ./"script" uninstall 21 | ``` 22 | **Remember to reboot after successful installation** 23 | ### Supported distributions 24 | - Debian >= 8 25 | - Ubuntu >= 15.04 26 | - Alpine Linux 27 | - Arch Linux 28 | 29 | ### Features 30 | - Currently there is choose between Apache and Lighttpd 31 | - Script is cleaning after yourself 32 | - Script asks for custom directories for rtorrent (or leaves default) 33 | - Install or uninstall 34 | -------------------------------------------------------------------------------- /alpine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source include.sh 4 | 5 | #Dependencies 6 | ######################################################### 7 | function DEPENDENCIES 8 | { 9 | apk update 10 | 11 | if [ $WEBSERVER = 1 ] 12 | then 13 | apk add apache2 apache2-utils php-apache2 14 | elif [ $WEBSERVER = 2 ] 15 | then 16 | apk add lighttpd lighttpd-mod_auth 17 | fi 18 | 19 | apk add rtorrent libtorrent xmlrpc-c openssl \ 20 | libtool cppunit-dev ncurses-dev ncurses ncurses-libs libssl1.0 \ 21 | php php-cgi php-curl php-cli screen wget libsigc++-dev 22 | } 23 | ######################################################### 24 | 25 | #Download 26 | ######################################################### 27 | function DOWNLOAD_STUFF 28 | { 29 | cd /tmp 30 | wget -c http://dl.bintray.com/novik65/generic/$RUTORRENT_TARBALL 31 | } 32 | ######################################################### 33 | 34 | #Service 35 | ######################################################### 36 | function OPENRC_SERVICE 37 | { 38 | cat > "/etc/init.d/rtorrentd" <<-EOF 39 | #!/sbin/runscript 40 | 41 | depend() 42 | { 43 | use net ypbind nis 44 | } 45 | 46 | start() 47 | { 48 | ebegin "Starting rtorrent" 49 | start-stop-daemon \ 50 | --start \ 51 | --make-pidfile \ 52 | --pidfile /var/run/rtorrentd.pid \ 53 | --background \ 54 | --user $NAME \ 55 | --name rtorrentd \ 56 | --exec /usr/bin/screen -- -D -m -S rtorrentd /usr/bin/rtorrent 57 | eend $? 58 | } 59 | 60 | stop() 61 | { 62 | ebegin "Stopping rtorrent" 63 | start-stop-daemon --stop --signal 15 \ 64 | --pidfile /var/run/rtorrentd.pid 65 | eend $? 66 | } 67 | EOF 68 | 69 | chmod +x /etc/init.d/rtorrentd 70 | /etc/init.d/rtorrentd start 71 | rc-update add rtorrentd default 72 | } 73 | ######################################################### 74 | 75 | #Rutorrent 76 | ######################################################### 77 | function RUTORRENT 78 | { 79 | echo "Type username for ruTorrent interface: " 80 | read RUTORRENT_USER 81 | echo "Type password for ruTorrent interface: " 82 | read RUTORRENT_PASS 83 | 84 | mv /tmp/$RUTORRENT_TARBALL /var/www/localhost/htdocs 85 | cd /var/www/localhost/htdocs 86 | tar -zxf $RUTORRENT_TARBALL 87 | rm $RUTORRENT_TARBALL 88 | } 89 | ######################################################### 90 | 91 | #Webservers 92 | ######################################################### 93 | function WEBSERVER_CONFIGURE 94 | { 95 | if [ $WEBSERVER = 1 ] 96 | then 97 | htpasswd -cb /var/www/localhost/htdocs/rutorrent/.htpasswd $RUTORRENT_USER $RUTORRENT_PASS 98 | if uname -m|grep -wq x86_64 99 | then 100 | cp /home/$NAME/seedbox/files/x86_64/mod_scgi.so /var/www/modules 101 | elif uname -m|grep -wq x86 102 | then 103 | cp /home/$NAME/seedbox/files/x86/mod_scgi.so /var/www/modules 104 | elif uname -m|grep -q arm 105 | then 106 | cp /home/$NAME/seedbox/files/armhf/mod_scgi.so /var/www/modules 107 | fi 108 | 109 | cat >> "/etc/apache2/httpd.conf" <<-EOF 110 | LoadModule scgi_module modules/mod_scgi.so 111 | 112 | SCGIMount /RPC2 127.0.0.1:5000 113 | 114 | 115 | AuthName "ruTorrent interface" 116 | AuthType Basic 117 | Require valid-user 118 | AuthUserFile /var/www/localhost/htdocs/rutorrent/.htpasswd 119 | 120 | EOF 121 | 122 | /etc/init.d/apache2 start 123 | rc-update add apache2 default 124 | 125 | elif [ $WEBSERVER = 2 ] 126 | then 127 | printf "$RUTORRENT_USER:$(openssl passwd -crypt $RUTORRENT_PASS)\n" >> /var/www/localhost/htdocs/rutorrent/.htpasswd 128 | 129 | sed -i -e 's@# "mod_auth",@ "mod_auth",@g' /etc/lighttpd/lighttpd.conf 130 | sed -i -e 's@# "mod_ssi",@ "mod_scgi",@g' /etc/lighttpd/lighttpd.conf 131 | sed -i -e 's@# include "mod_fastcgi.conf"@include "mod_fastcgi.conf"@g' /etc/lighttpd/lighttpd.conf 132 | sed -i -e "s@;cgi.fix_pathinfo=1@cgi.fix_pathinfo=1@g" /etc/php/php.ini 133 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 134 | auth.backend = "htpasswd" 135 | auth.backend.htpasswd.userfile = "/var/www/localhost/htdocs/rutorrent/.htpasswd" 136 | auth.require = ( "/rutorrent" => 137 | ( 138 | "method" => "basic", 139 | "realm" => "ruTorrent interface", 140 | "require" => "valid-user" 141 | ), 142 | ) 143 | EOF 144 | 145 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 146 | scgi.server = ( 147 | "/RPC2" => 148 | ( "127.0.0.1" => 149 | ( 150 | "host" => "127.0.0.1", 151 | "port" => 5000, 152 | "check-local" => "disable" 153 | ) 154 | ) 155 | ) 156 | EOF 157 | 158 | /etc/init.d/lighttpd restart 159 | rc-update add lighttpd default 160 | fi 161 | } 162 | 163 | #Uninstall 164 | ######################################################### 165 | UNINSTALL() 166 | { 167 | apk del rtorrent libtorrent xmlrpc-c openssl cppunit-dev ncurses-dev ncurses \ 168 | ncurses-libs libssl1.0 php php-cgi php-curl php-cli screen libsigc++-dev 169 | 170 | if apk info |grep -q apache 171 | then 172 | apk del apache2 apache2-utils php-apache2 173 | elif apk info |grep -q lighttpd 174 | then 175 | apk del lighttpd lighttpd-mod_auth 176 | fi 177 | 178 | RTORRENT_DOWNLOAD_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^directory/ {print $3;}')" 179 | RTORRENT_SESSION_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^session/ {print $3;}')" 180 | 181 | rm -R "$RTORRENT_DOWNLOAD_DIR" 182 | rm -R "$RTORRENT_SESSION_DIR" 183 | rm -R /home/$NAME/.rtorrent.rc 184 | rm -R /var/www/localhost/htdocs/rutorrent 185 | rm /etc/init.d/rtorrentd 186 | } 187 | ######################################################### 188 | 189 | #Main 190 | ######################################################### 191 | CHECK_ROOT 192 | if [ $SETUP == install ] 193 | then 194 | GREETINGS 195 | GET_USERNAME 196 | GET_WEBSERVER 197 | DEPENDENCIES 198 | DOWNLOAD_STUFF 199 | OPENRC_SERVICE 200 | RUTORRENT 201 | WEBSERVER_CONFIGURE 202 | RTORRENT_CONFIGURE 203 | COMPLETE 204 | elif [ $SETUP == uninstall ] 205 | then 206 | UNINSTALL 207 | fi 208 | ######################################################### 209 | -------------------------------------------------------------------------------- /arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source include.sh 4 | 5 | #Dependencies 6 | ######################################################### 7 | DEPENDENCIES() 8 | { 9 | if [ $WEBSERVER = 1 ] 10 | then 11 | pacman -Sy --noconfirm apache php-apache 12 | elif [ $WEBSERVER = 2 ] 13 | then 14 | pacman -Sy --noconfirm lighttpd 15 | fi 16 | 17 | pacman -S --noconfirm rtorrent libtorrent xmlrpc-c openssl libtool cppunit ncurses php php-cgi screen wget libsigc++ 18 | } 19 | ######################################################### 20 | 21 | #Download 22 | ######################################################### 23 | DOWNLOAD_STUFF() 24 | { 25 | cd /tmp 26 | wget -c http://dl.bintray.com/novik65/generic/$RUTORRENT_TARBALL 27 | } 28 | ######################################################### 29 | 30 | #Service 31 | ######################################################### 32 | SYSTEMD_SERVICE() 33 | { 34 | cat > "/etc/systemd/system/rtorrent.service" <<-EOF 35 | [Unit] 36 | Description=rtorrent 37 | 38 | [Service] 39 | Type=oneshot 40 | RemainAfterExit=yes 41 | User=$NAME 42 | ExecStart=/usr/bin/screen -S rtorrent -fa -d -m rtorrent 43 | ExecStop=/usr/bin/screen -X -S rtorrent quit 44 | 45 | [Install] 46 | WantedBy=default.target 47 | EOF 48 | 49 | systemctl start rtorrent.service 50 | systemctl enable rtorrent.service 51 | } 52 | ######################################################### 53 | 54 | #Rutorrent 55 | ######################################################### 56 | RUTORRENT() 57 | { 58 | echo "Type username for ruTorrent interface: " 59 | read RUTORRENT_USER 60 | echo "Type password for ruTorrent interface: " 61 | read RUTORRENT_PASS 62 | 63 | mv /tmp/$RUTORRENT_TARBALL /srv/http 64 | cd /srv/http 65 | tar -xf $RUTORRENT_TARBALL 66 | rm $RUTORRENT_TARBALL 67 | 68 | echo "$NAME:x:1000:" >> /etc/group 69 | } 70 | ######################################################### 71 | 72 | #Webservers 73 | ######################################################### 74 | WEBSERVER_CONFIGURE() 75 | { 76 | if [ $WEBSERVER = 1 ] 77 | then 78 | htpasswd -cb /srv/http/rutorrent/.htpasswd $RUTORRENT_USER $RUTORRENT_PASS 79 | if uname -m|grep -wq x86_64 80 | then 81 | cp /home/$NAME/seedbox/files/x86_64/mod_scgi.so /etc/httpd/modules 82 | elif uname -m|grep -wq x86 83 | then 84 | cp /home/$NAME/seedbox/files/x86/mod_scgi.so /etc/httpd/modules 85 | elif uname -m|grep -q arm 86 | then 87 | cp /home/$NAME/seedbox/files/armhf/mod_scgi.so /etc/httpd/modules 88 | fi 89 | 90 | echo "Include conf/extra/php7_module.conf" >> /etc/httpd/conf/httpd.conf 91 | 92 | echo "LoadModule php7_module modules/libphp7.so" >> /etc/httpd/conf/httpd.conf 93 | 94 | echo "AddType application/x-httpd-php .php" >> /etc/httpd/conf/httpd.conf 95 | 96 | echo "AddType application/x-httpd-php-source .phps" >> /etc/httpd/conf/httpd.conf 97 | 98 | sed -i -e "s@LoadModule mpm_event_module modules/mod_mpm_event.so@#LoadModule mpm_event_module modules/mod_mpm_event.so@g" /etc/httpd/conf/httpd.conf 99 | 100 | sed -i -e "s@#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so@LoadModule mpm_prefork_module modules/mod_mpm_prefork.so@g" /etc/httpd/conf/httpd.conf 101 | 102 | cat >> "/etc/httpd/conf/httpd.conf" <<-EOF 103 | LoadModule scgi_module modules/mod_scgi.so 104 | 105 | SCGIMount /RPC2 127.0.0.1:5000 106 | 107 | 108 | AuthName "ruTorrent interface" 109 | AuthType Basic 110 | Require valid-user 111 | AuthUserFile /srv/http/rutorrent/.htpasswd 112 | 113 | EOF 114 | 115 | systemctl start httpd.service 116 | systemctl enable httpd.service 117 | 118 | elif [ $WEBSERVER = 2 ] 119 | then 120 | printf "$RUTORRENT_USER:$(openssl passwd -crypt $RUTORRENT_PASS)\n" >> /srv/http/rutorrent/.htpasswd 121 | 122 | if ! grep --quiet "mod_auth" /etc/lighttpd/lighttpd.conf 123 | then 124 | echo 'server.modules += ( "mod_auth" )' >> /etc/lighttpd/lighttpd.conf 125 | fi 126 | 127 | if ! grep --quiet "mod_scgi" /etc/lighttpd/lighttpd.conf 128 | then 129 | echo 'server.modules += ( "mod_scgi" )' >> /etc/lighttpd/lighttpd.conf 130 | fi 131 | 132 | if ! grep --quiet "mod_fcgi" /etc/lighttpd/lighttpd.conf 133 | then 134 | echo 'server.modules += ( "mod_fastcgi" )' >> /etc/lighttpd/lighttpd.conf 135 | fi 136 | 137 | sed -i -e "s@;cgi.fix_pathinfo=1@cgi.fix_pathinfo=1@g" /etc/php/php.ini 138 | 139 | if ! grep --quiet "fastcgi.server" /etc/lighttpd/lighttpd.conf 140 | then 141 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 142 | fastcgi.server = ( ".php" => (( 143 | "bin-path" => "/usr/bin/php-cgi", 144 | "socket" => "/run/lighttpd/php.socket" 145 | ))) 146 | EOF 147 | fi 148 | 149 | if ! grep --quiet "auth.backend.htpasswd.userfile" /etc/lighttpd/lighttpd.conf 150 | then 151 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 152 | auth.backend = "htpasswd" 153 | auth.backend.htpasswd.userfile = "/srv/http/rutorrent/.htpasswd" 154 | auth.require = ( "/rutorrent" => 155 | ( 156 | "method" => "basic", 157 | "realm" => "ruTorrent interface", 158 | "require" => "valid-user" 159 | ), 160 | ) 161 | EOF 162 | fi 163 | 164 | if ! grep --quiet "scgi.server" /etc/lighttpd/lighttpd.conf 165 | then 166 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 167 | scgi.server = ( 168 | "/RPC2" => 169 | ( "127.0.0.1" => 170 | ( 171 | "host" => "127.0.0.1", 172 | "port" => 5000, 173 | "check-local" => "disable" 174 | ) 175 | ) 176 | ) 177 | EOF 178 | fi 179 | 180 | systemctl start lighttpd.service 181 | systemctl enable lighttpd.service 182 | fi 183 | } 184 | 185 | #Uninstall 186 | ######################################################### 187 | UNINSTALL() 188 | { 189 | pacman -Rnsc rtorrent libtorrent xmlrpc-c cppunit php php-cgi screen libsigc++ 190 | 191 | if pacman -Qs apache > /dev/null 192 | then 193 | pacman -Rnsc apache apr-util apr 194 | 195 | elif pacman -Qs lighttpd > /dev/null 196 | then 197 | pacman -Rnsc lighttpd 198 | fi 199 | 200 | RTORRENT_DOWNLOAD_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^directory/ {print $3;}')" 201 | RTORRENT_SESSION_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^session/ {print $3;}')" 202 | 203 | rm -R "$RTORRENT_DOWNLOAD_DIR" 204 | rm -R "$RTORRENT_SESSION_DIR" 205 | rm -R /home/$NAME/.rtorrent.rc 206 | rm -R /srv/http/rutorrent 207 | rm /etc/systemd/system/rtorrent.service 208 | } 209 | ######################################################### 210 | 211 | #Main 212 | ######################################################### 213 | CHECK_ROOT 214 | if [ $SETUP = install ] 215 | then 216 | GREETINGS 217 | GET_USERNAME 218 | GET_WEBSERVER 219 | DEPENDENCIES 220 | DOWNLOAD_STUFF 221 | SYSTEMD_SERVICE 222 | RUTORRENT 223 | WEBSERVER_CONFIGURE 224 | RTORRENT_CONFIGURE 225 | COMPLETE 226 | elif [ $SETUP = uninstall ] 227 | then 228 | UNINSTALL 229 | fi 230 | ######################################################### 231 | -------------------------------------------------------------------------------- /files/armhf/mod_scgi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dawidd6/seedbox/9a7b58600bc7cd0f8af30bcafcc430aea8f796f7/files/armhf/mod_scgi.so -------------------------------------------------------------------------------- /files/x86/mod_scgi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dawidd6/seedbox/9a7b58600bc7cd0f8af30bcafcc430aea8f796f7/files/x86/mod_scgi.so -------------------------------------------------------------------------------- /files/x86_64/mod_scgi.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dawidd6/seedbox/9a7b58600bc7cd0f8af30bcafcc430aea8f796f7/files/x86_64/mod_scgi.so -------------------------------------------------------------------------------- /include.sh: -------------------------------------------------------------------------------- 1 | #Variables 2 | ######################################################### 3 | NAME="$(printf '%s\n' "${SUDO_USER:-$USER}")" 4 | BOOL=true 5 | CHOICE= 6 | 7 | RTORRENT_DOWNLOAD_DIR= 8 | RTORRENT_SESSION_DIR= 9 | 10 | LIBTORRENT_TARBALL=libtorrent-0.13.6.tar.gz 11 | LIBTORRENT_DIR=libtorrent-0.13.6 12 | 13 | RTORRENT_TARBALL=rtorrent-0.9.6.tar.gz 14 | RTORRENT_DIR=rtorrent-0.9.6 15 | 16 | RUTORRENT_TARBALL=rutorrent-3.6.tar.gz 17 | 18 | RUTORRENT_USER= 19 | RUTORRENT_PASS= 20 | 21 | WEBSERVER=0 22 | 23 | SETUP="$1" 24 | ######################################################### 25 | 26 | #Greetings 27 | ######################################################### 28 | GREETINGS() 29 | { 30 | echo -e "\n\e[1;36mVersions of components to be installed:\e[0m" 31 | echo "-----------------------------------------------------" 32 | echo -e "\e[1;32mxmlrpc-c\e[0m - \e[1;31mstable\e[0m" 33 | echo -e "\e[1;32mlibtorrent\e[0m - \e[1;31m0.13.6\e[0m" 34 | echo -e "\e[1;32mrtorrent\e[0m - \e[1;31m0.9.6\e[0m" 35 | echo -e "\e[1;32mrutorrent\e[0m - \e[1;31m3.6\e[0m" 36 | echo "-----------------------------------------------------" 37 | echo -e "\nScript has been assembled by \e[1mdawidd6\e[0m\n" 38 | } 39 | ######################################################### 40 | 41 | #Various Shit 42 | ######################################################### 43 | CHECK_ROOT() 44 | { 45 | if [ $(id -u) != 0 ] 46 | then 47 | echo "This script must be run as root" 48 | exit 1 49 | fi 50 | } 51 | 52 | GET_USERNAME() 53 | { 54 | echo "Please type your system's username (not root): " 55 | read NAME 56 | 57 | if [ $NAME = root ] 58 | then 59 | echo "You can't run rtorrent as root for security purposes" 60 | echo "Please run script again and type a valid username" 61 | exit 1 62 | 63 | elif [ $(printf '%s\n' "${SUDO_USER:-$USER}") = $NAME ] 64 | then 65 | echo "Continuing..." 66 | 67 | else 68 | echo "This user does not exist" 69 | echo "Please run script again and type a valid username" 70 | exit 1 71 | 72 | fi 73 | sleep 3 74 | } 75 | 76 | GET_WEBSERVER() 77 | { 78 | echo "Please type which webserver would you use ('1' or '2'):" 79 | echo "1) Apache" 80 | echo "2) Lighttpd" 81 | 82 | until [ $WEBSERVER = 1 ] || [ $WEBSERVER = 2 ] 83 | do 84 | read WEBSERVER 85 | if [ $WEBSERVER != 1 ] && [ $WEBSERVER != 2 ] 86 | then 87 | echo "Please type a valid number" 88 | fi 89 | done 90 | } 91 | ######################################################### 92 | 93 | #Rtorrent Configuration 94 | ######################################################### 95 | RTORRENT_CONFIGURE() 96 | { 97 | cat > "/home/$NAME/.rtorrent.rc" <<-EOF 98 | # This is an example resource file for rTorrent. Copy to 99 | # ~/.rtorrent.rc and enable/modify the options as needed. Remember to 100 | # uncomment the options you wish to enable. 101 | 102 | # Maximum and minimum number of peers to connect to per torrent. 103 | #min_peers = 40 104 | #max_peers = 100 105 | 106 | # Same as above but for seeding completed torrents (-1 = same as downloading) 107 | #min_peers_seed = 10 108 | #max_peers_seed = 50 109 | 110 | # Maximum number of simultanious uploads per torrent. 111 | #max_uploads = 15 112 | 113 | # Global upload and download rate in KiB. "0" for unlimited. 114 | #download_rate = 0 115 | #upload_rate = 0 116 | 117 | # Default directory to save the downloaded torrents. 118 | directory = /home/$NAME/rtorrent/downloads 119 | 120 | # Default session directory. Make sure you don't run multiple instance 121 | # of rtorrent using the same session directory. Perhaps using a 122 | # relative path? 123 | session = /home/$NAME/rtorrent/.rtorrent-session 124 | 125 | # Watch a directory for new torrents, and stop those that have been 126 | # deleted. 127 | #schedule = watch_directory,5,5,load_start=./watch/*.torrent 128 | #schedule = untied_directory,5,5,stop_untied= 129 | 130 | # Close torrents when diskspace is low. 131 | schedule = low_diskspace,5,60,close_low_diskspace=100M 132 | 133 | # The ip address reported to the tracker. 134 | #ip = 127.0.0.1 135 | #ip = rakshasa.no 136 | 137 | # The ip address the listening socket and outgoing connections is 138 | # bound to. 139 | #bind = 127.0.0.1 140 | #bind = rakshasa.no 141 | 142 | # Port range to use for listening. 143 | port_range = 6790-6999 144 | 145 | # Start opening ports at a random position within the port range. 146 | #port_random = no 147 | 148 | # Check hash for finished torrents. Might be usefull until the bug is 149 | # fixed that causes lack of diskspace not to be properly reported. 150 | #check_hash = no 151 | 152 | # Set whetever the client should try to connect to UDP trackers. 153 | #use_udp_trackers = yes 154 | 155 | # Alternative calls to bind and ip that should handle dynamic ip's. 156 | #schedule = ip_tick,0,1800,ip=rakshasa 157 | #schedule = bind_tick,0,1800,bind=rakshasa 158 | 159 | # Encryption options, set to none (default) or any combination of the following: 160 | # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext 161 | # 162 | # The example value allows incoming encrypted connections, starts unencrypted 163 | # outgoing connections but retries with encryption if they fail, preferring 164 | # plaintext to RC4 encryption after the encrypted handshake 165 | # 166 | encryption = allow_incoming,enable_retry,try_outgoing 167 | 168 | # Enable DHT support for trackerless torrents or when all trackers are down. 169 | # May be set to "disable" (completely disable DHT), "off" (do not start DHT), 170 | # "auto" (start and stop DHT as needed), or "on" (start DHT immediately). 171 | # The default is "off". For DHT to work, a session directory must be defined. 172 | # 173 | # dht = auto 174 | 175 | # UDP port to use for DHT. 176 | # 177 | # dht_port = 6881 178 | 179 | # Enable peer exchange (for torrents not marked private) 180 | # 181 | # peer_exchange = yes 182 | 183 | # 184 | # Do not modify the following parameters unless you know what you're doing. 185 | # 186 | 187 | # Hash read-ahead controls how many MB to request the kernel to read 188 | # ahead. If the value is too low the disk may not be fully utilized, 189 | # while if too high the kernel might not be able to keep the read 190 | # pages in memory thus end up trashing. 191 | #hash_read_ahead = 10 192 | 193 | # Interval between attempts to check the hash, in milliseconds. 194 | #hash_interval = 100 195 | 196 | # Number of attempts to check the hash while using the mincore status, 197 | # before forcing. Overworked systems might need lower values to get a 198 | # decent hash checking rate. 199 | #hash_max_tries = 10 200 | 201 | scgi_port = 127.0.0.1:5000 202 | EOF 203 | 204 | echo -e "\nDefault directory for downloads is: /home/$NAME/rtorrent/downloads" 205 | echo -e "Default directory for session files is: /home/$NAME/rtorrent/.rtorrent-session\n" 206 | echo "Do you want to set custom directories for rtorrent? ('yes' or 'no'): " 207 | read CHOICE 208 | 209 | while [ $BOOL = true ] 210 | do 211 | 212 | if [ $CHOICE = yes ] 213 | then 214 | echo "Type a directory to where will rtorrent download files: " 215 | read RTORRENT_DOWNLOAD_DIR 216 | sed -i -e "s@~/rtorrent/downloads@$RTORRENT_DOWNLOAD_DIR@g" /home/$NAME/.rtorrent.rc 217 | echo "Type a directory to where will rtorrent save session files: " 218 | read RTORRENT_SESSION_DIR 219 | sed -i -e "s@~/rtorrent/.rtorrent-session@$RTORRENT_SESSION_DIR@g" /home/$NAME/.rtorrent.rc 220 | mkdir -p $RTORRENT_DOWNLOAD_DIR 221 | mkdir -p $RTORRENT_SESSION_DIR 222 | chown -R $NAME:$NAME $RTORRENT_DOWNLOAD_DIR 223 | chown -R $NAME:$NAME $RTORRENT_SESSION_DIR 224 | BOOL=false 225 | 226 | elif [ $CHOICE = no ] 227 | then 228 | mkdir -p /home/$NAME/rtorrent/.rtorrent-session 229 | mkdir -p /home/$NAME/rtorrent/downloads 230 | chown -R $NAME:$NAME /home/$NAME/rtorrent/.rtorrent-session 231 | chown -R $NAME:$NAME /home/$NAME/rtorrent/downloads 232 | echo "Default..." 233 | BOOL=false 234 | sleep 3 235 | 236 | else 237 | echo "Type 'yes' or 'no': " 238 | read CHOICE 239 | 240 | fi 241 | done 242 | 243 | chown $NAME:$NAME /home/$NAME/.rtorrent.rc 244 | } 245 | ######################################################### 246 | 247 | #Complete 248 | ######################################################### 249 | COMPLETE() 250 | { 251 | echo -e "\n***INSTALLATION COMPLETED***" 252 | echo "You should be able after reboot to log in to rutorrent interface at: " 253 | echo "http://localhost:80/rutorrent" 254 | echo "with this authentication: " 255 | echo "-----------------------------------------------------" 256 | echo $RUTORRENT_USER 257 | echo $RUTORRENT_PASS 258 | echo "-----------------------------------------------------" 259 | echo "XMLRPC-C is working on /RPC2 address" 260 | echo "Please reboot your system to ensure all is working proper!" 261 | } 262 | ######################################################### 263 | -------------------------------------------------------------------------------- /plugins.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Variables 4 | ####################################### 5 | CHOICE= 6 | 7 | ####################################### 8 | function CHECK_ROOT 9 | { 10 | if [ $(id -u) != 0 ] 11 | then 12 | echo "This script must be run as root" 13 | exit 1 14 | fi 15 | } 16 | 17 | function LIST_AVAILABLE 18 | { 19 | echo "Available plugins:" 20 | 21 | if [ -d /var/www/html/rutorrent/plugins/_getdir ] 22 | then 23 | echo "1) _getdir (installed)" 24 | else 25 | echo "1) _getdir" 26 | fi 27 | 28 | if [ -d /var/www/html/rutorrent/plugins/_noty ] 29 | then 30 | echo "2) _noty (installed)" 31 | else 32 | echo "2) _noty" 33 | fi 34 | 35 | echo "3) _task" 36 | echo "4) autotools" 37 | echo "5) check_port" 38 | echo "6) chunks" 39 | echo "7) cookies" 40 | echo "8) cpuload" 41 | echo "9) create" 42 | echo "10) data" 43 | echo "11) datadir" 44 | echo "12) diskspace" 45 | echo "13) edit" 46 | echo "14) erasedata" 47 | echo "15) extratio" 48 | echo "16) extsearch" 49 | echo "17) feeds" 50 | echo "18) filedrop" 51 | echo "19) geoip" 52 | echo "20) history" 53 | echo "21) httprpc" 54 | echo "22) ipad" 55 | echo "23) loginmgr" 56 | echo "24) lookat" 57 | echo "25) mediainfo" 58 | echo "26) ratio" 59 | echo "27) retrackers" 60 | echo "28) rpc" 61 | echo "29) rss" 62 | echo "30) rssurlrewrite" 63 | echo "31) rutracker_check" 64 | echo "32) scheduler" 65 | echo "33) screenshots" 66 | echo "34) seedingtime" 67 | echo "35) show_peers_like_wtorrent" 68 | echo "36) source" 69 | echo "37) theme" 70 | echo "38) throttle" 71 | echo "39) tracklabels" 72 | echo "40) trafic" 73 | echo "41) unpack" 74 | } 75 | 76 | function GET_CHOOSE 77 | { 78 | read -a CHOICE 79 | 80 | cd /var/www/html/rutorrent/plugins 81 | 82 | for i in "${CHOICE[@]}" 83 | do 84 | case $i in 85 | "1") wget -c https://bintray.com/artifact/download/novik65/generic/plugins/_getdir-3.6.tar.gz 86 | tar -xf _getdir-3.6.tar.gz 87 | rm _getdir-3.6.tar.gz;; 88 | "2") wget -c https://bintray.com/artifact/download/novik65/generic/plugins/_noty-3.6.tar.gz 89 | tar -xf _noty-3.6.tar.gz 90 | rm _noty-3.6.tar.gz;; 91 | "3") 92 | "q") exit 0;; 93 | *) echo "Number out of range";; 94 | esac 95 | done 96 | 97 | } 98 | 99 | CHECK_ROOT 100 | LIST_AVAILABLE 101 | GET_CHOOSE 102 | -------------------------------------------------------------------------------- /ubuntu-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source include.sh 4 | 5 | #Dependencies 6 | ######################################################### 7 | DEPENDENCIES() 8 | { 9 | apt-get update 10 | 11 | if [ $WEBSERVER = 1 ] 12 | then 13 | apt-get -y install apache2 apache2-utils libapache2-mod-scgi libapache2-mod-php5 14 | elif [ $WEBSERVER = 2 ] 15 | then 16 | apt-get -y install lighttpd 17 | fi 18 | 19 | apt-get -y install openssl build-essential libsigc++-2.0-dev libxmlrpc-core-c3-dev\ 20 | libcurl4-openssl-dev automake libtool libcppunit-dev libncurses5-dev \ 21 | php5 php5-cgi php5-curl php5-cli screen unzip libssl-dev wget curl 22 | } 23 | ######################################################### 24 | 25 | #Download 26 | ######################################################### 27 | DOWNLOAD_STUFF() 28 | { 29 | cd /tmp 30 | wget -c http://rtorrent.net/downloads/$LIBTORRENT_TARBALL 31 | wget -c http://rtorrent.net/downloads/$RTORRENT_TARBALL 32 | wget -c http://dl.bintray.com/novik65/generic/$RUTORRENT_TARBALL 33 | } 34 | ######################################################### 35 | 36 | #Compile 37 | ######################################################### 38 | LIBTORRENT_COMPILE() 39 | { 40 | cd /tmp 41 | tar -xf $LIBTORRENT_TARBALL 42 | rm $LIBTORRENT_TARBALL 43 | cd $LIBTORRENT_DIR 44 | 45 | ./autogen.sh 46 | ./configure 47 | make 48 | make install 49 | 50 | cd .. 51 | rm -R $LIBTORRENT_DIR 52 | } 53 | 54 | RTORRENT_COMPILE() 55 | { 56 | cd /tmp 57 | tar -xf $RTORRENT_TARBALL 58 | rm $RTORRENT_TARBALL 59 | cd $RTORRENT_DIR 60 | 61 | ./autogen.sh 62 | ./configure --with-xmlrpc-c 63 | make 64 | make install 65 | 66 | cd .. 67 | rm -R $RTORRENT_DIR 68 | 69 | ldconfig 70 | } 71 | ######################################################### 72 | 73 | #Service 74 | ######################################################### 75 | SYSTEMD_SERVICE() 76 | { 77 | cat > "/etc/systemd/system/rtorrent.service" <<-EOF 78 | [Unit] 79 | Description=rtorrent 80 | 81 | [Service] 82 | Type=oneshot 83 | RemainAfterExit=yes 84 | User=$NAME 85 | ExecStart=/usr/bin/screen -S rtorrent -fa -d -m rtorrent 86 | ExecStop=/usr/bin/screen -X -S rtorrent quit 87 | 88 | [Install] 89 | WantedBy=default.target 90 | EOF 91 | 92 | systemctl start rtorrent.service 93 | systemctl enable rtorrent.service 94 | } 95 | ######################################################### 96 | 97 | #Rutorrent 98 | ######################################################### 99 | RUTORRENT() 100 | { 101 | echo "Type username for ruTorrent interface: " 102 | read RUTORRENT_USER 103 | echo "Type password for ruTorrent interface: " 104 | read RUTORRENT_PASS 105 | 106 | mv /tmp/$RUTORRENT_TARBALL /var/www/html 107 | cd /var/www/html 108 | tar -xf $RUTORRENT_TARBALL 109 | chown -R www-data:www-data rutorrent 110 | chmod -R 755 rutorrent 111 | 112 | rm $RUTORRENT_TARBALL 113 | 114 | } 115 | ######################################################### 116 | 117 | #Webservers 118 | ######################################################### 119 | WEBSERVER_CONFIGURE() 120 | { 121 | if [ $WEBSERVER = 1 ] 122 | then 123 | htpasswd -cb /var/www/html/rutorrent/.htpasswd $RUTORRENT_USER $RUTORRENT_PASS 124 | 125 | if ! test -h /etc/apache2/mods-enabled/scgi.load 126 | then 127 | ln -s /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load 128 | fi 129 | 130 | if ! grep --quiet "^Listen 80$" /etc/apache2/ports.conf 131 | then 132 | echo "Listen 80" >> /etc/apache2/ports.conf 133 | fi 134 | 135 | if ! grep --quiet "^ServerName$" /etc/apache2/apache2.conf 136 | then 137 | echo "ServerName localhost" >> /etc/apache2/apache2.conf 138 | fi 139 | 140 | if ! test -f /etc/apache2/sites-available/001-default-rutorrent.conf 141 | then 142 | cat > "/etc/apache2/sites-available/001-default-rutorrent.conf" <<-EOF 143 | 144 | #ServerName www.example.com 145 | ServerAdmin webmaster@localhost 146 | DocumentRoot /var/www/html 147 | 148 | CustomLog /var/log/apache2/rutorrent.log vhost_combined 149 | ErrorLog /var/log/apache2/rutorrent_error.log 150 | SCGIMount /RPC2 127.0.0.1:5000 151 | 152 | 153 | AuthName "ruTorrent interface" 154 | AuthType Basic 155 | Require valid-user 156 | AuthUserFile /var/www/html/rutorrent/.htpasswd 157 | 158 | 159 | EOF 160 | 161 | a2ensite 001-default-rutorrent.conf 162 | a2dissite 000-default.conf 163 | systemctl restart apache2.service 164 | systemctl enable apache2.service 165 | fi 166 | 167 | elif [ $WEBSERVER = 2 ] 168 | then 169 | printf "$RUTORRENT_USER:$(openssl passwd -crypt $RUTORRENT_PASS)\n" >> /var/www/html/rutorrent/.htpasswd 170 | 171 | if ! grep --quiet "mod_auth" /etc/lighttpd/lighttpd.conf 172 | then 173 | echo 'server.modules += ( "mod_auth" )' >> /etc/lighttpd/lighttpd.conf 174 | fi 175 | 176 | if ! grep --quiet "mod_scgi" /etc/lighttpd/lighttpd.conf 177 | then 178 | echo 'server.modules += ( "mod_scgi" )' >> /etc/lighttpd/lighttpd.conf 179 | fi 180 | 181 | if ! grep --quiet "mod_fcgi" /etc/lighttpd/lighttpd.conf 182 | then 183 | echo 'server.modules += ( "mod_fastcgi" )' >> /etc/lighttpd/lighttpd.conf 184 | fi 185 | 186 | if ! grep --quiet "cgi.fix_pathinfo=1" /etc/php5/cgi/php.ini 187 | then 188 | echo "cgi.fix_pathinfo=1" >> /etc/php5/cgi/php.ini 189 | fi 190 | 191 | if ! grep --quiet "fastcgi.server" /etc/lighttpd/lighttpd.conf 192 | then 193 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 194 | fastcgi.server = ( ".php" => (( 195 | "bin-path" => "/usr/bin/php5-cgi", 196 | "socket" => "/tmp/php.socket" 197 | ))) 198 | EOF 199 | fi 200 | 201 | if ! grep --quiet "auth.backend.htpasswd.userfile" /etc/lighttpd/lighttpd.conf 202 | then 203 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 204 | auth.backend = "htpasswd" 205 | auth.backend.htpasswd.userfile = "/var/www/html/rutorrent/.htpasswd" 206 | auth.require = ( "/rutorrent" => 207 | ( 208 | "method" => "basic", 209 | "realm" => "ruTorrent interface", 210 | "require" => "valid-user" 211 | ), 212 | ) 213 | EOF 214 | fi 215 | 216 | if ! grep --quiet "scgi.server" /etc/lighttpd/lighttpd.conf 217 | then 218 | cat >> "/etc/lighttpd/lighttpd.conf" <<-EOF 219 | scgi.server = ( 220 | "/RPC2" => 221 | ( "127.0.0.1" => 222 | ( 223 | "host" => "127.0.0.1", 224 | "port" => 5000, 225 | "check-local" => "disable" 226 | ) 227 | ) 228 | ) 229 | EOF 230 | fi 231 | 232 | systemctl restart lighttpd 233 | systemctl enable lighttpd 234 | fi 235 | } 236 | ######################################################### 237 | 238 | #Uninstall 239 | ######################################################### 240 | UNINSTALL() 241 | { 242 | cd /tmp 243 | 244 | wget -c http://rtorrent.net/downloads/$LIBTORRENT_TARBALL 245 | wget -c http://rtorrent.net/downloads/$RTORRENT_TARBALL 246 | 247 | tar -xf $RTORRENT_TARBALL 248 | rm $RTORRENT_TARBALL 249 | cd $RTORRENT_DIR 250 | ./autogen.sh 251 | ./configure --with-xmlrpc-c 252 | make uninstall 253 | cd .. 254 | rm -R $RTORRENT_DIR 255 | 256 | tar -xf $LIBTORRENT_TARBALL 257 | rm $LIBTORRENT_TARBALL 258 | cd $LIBTORRENT_DIR 259 | ./autogen.sh 260 | ./configure 261 | make uninstall 262 | cd .. 263 | rm -R $LIBTORRENT_DIR 264 | 265 | ldconfig 266 | 267 | 268 | apt-get purge openssl libsigc++-2.0-dev \ 269 | libcurl4-openssl-dev automake libcppunit-dev libncurses5-dev \ 270 | php5 php5-cgi php5-curl php5-cli screen libssl-dev libxmlrpc-core-c3-dev 271 | 272 | if dpkg -l|grep -q apache2 273 | then 274 | apt-get purge apache2 apache2-utils libapache2-mod-scgi libapache2-mod-php5 275 | elif dpkg -l|grep -q lighttpd 276 | then 277 | apt-get purge lighttpd 278 | fi 279 | 280 | apt-get autoremove --purge 281 | 282 | RTORRENT_DOWNLOAD_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^directory/ {print $3;}')" 283 | RTORRENT_SESSION_DIR="$(cat /home/$NAME/.rtorrent.rc |awk '/^session/ {print $3;}')" 284 | 285 | rm -R "$RTORRENT_DOWNLOAD_DIR" 286 | rm -R "$RTORRENT_SESSION_DIR" 287 | rm -R /home/$NAME/.rtorrent.rc 288 | rm -R /var/www/html/rutorrent 289 | rm /etc/systemd/system/rtorrent.service 290 | } 291 | ######################################################### 292 | 293 | #Main 294 | ######################################################### 295 | CHECK_ROOT 296 | if [ $SETUP == install ] 297 | then 298 | GREETINGS 299 | GET_USERNAME 300 | GET_WEBSERVER 301 | DEPENDENCIES 302 | DOWNLOAD_STUFF 303 | LIBTORRENT_COMPILE 304 | RTORRENT_COMPILE 305 | SYSTEMD_SERVICE 306 | RUTORRENT 307 | WEBSERVER_CONFIGURE 308 | RTORRENT_CONFIGURE 309 | COMPLETE 310 | elif [ $SETUP == uninstall ] 311 | then 312 | UNINSTALL 313 | fi 314 | ######################################################### 315 | --------------------------------------------------------------------------------