SHARE
TWEET

rtorrent rutorrent raspberry pi

a guest Oct 17th, 2012 1,009 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #http://pastebin.ubuntu.com/798506/
  3.  
  4. clear
  5.  
  6. if [ "$(id -u)" != "0" ]; then
  7.         echo
  8.         echo "This script must be run as root." 1>&2
  9.         echo
  10.         exit 1
  11. fi
  12.  
  13. con=0
  14. while [ $con -eq 0 ]; do
  15.  
  16.         echo -n "Please type a valid system user: "
  17.         read -e user
  18.         uid=$(cat /etc/passwd | grep "$user": | cut -d: -f3)
  19.  
  20.         if [ -z $(cat /etc/passwd | grep "$user":) ]; then
  21.                 echo
  22.                 echo "This user does not exist!"
  23.  
  24.         elif [ $uid -lt 999 ]; then
  25.                 echo
  26.                 echo "That user's UID is too low!"
  27.  
  28.         elif [ $user == nobody ]; then
  29.                 echo
  30.                 echo "You cant use 'nobody' as user!"
  31.         else
  32.                 con=1
  33.         fi
  34. done
  35.  
  36. homedir=$(cat /etc/passwd | grep "$user": | cut -d: -f6)
  37.  
  38. apt-get install openssl subversion apache2 build-essential libsigc++-2.0-dev libcurl4-openssl-dev automake libtool libcppunit-dev libncurses5-dev libapache2-mod-scgi php5 php5-curl php5-cli libapache2-mod-php5 screen
  39.  
  40. svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
  41. cd xmlrpc-c
  42. ./configure --disable-cplusplus
  43. make
  44. make install
  45. cd ..
  46. rm -rv xmlrpc-c
  47.  
  48. wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.9.tar.gz
  49. tar -zxvf libtorrent-0.12.9.tar.gz
  50. cd libtorrent-0.12.9
  51. ./autogen.sh
  52. ./configure
  53. make
  54. make install
  55. cd ..
  56. rm -rv libtorrent-0.12.9*
  57.  
  58. wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.9.tar.gz
  59. tar -zxvf rtorrent-0.8.9.tar.gz
  60. cd rtorrent-0.8.9
  61. ./autogen.sh
  62. ./configure --with-xmlrpc-c
  63. make
  64. make install
  65. ldconfig
  66. cd  ..
  67. rm -rv rtorrent-0.8.9*
  68.  
  69. if [ ! -d "$homedir"/.rtorrent-session ]; then
  70.         mkdir "$homedir"/.rtorrent-session
  71.         chown "$user"."$user" "$homedir"/.rtorrent-session
  72. else
  73.         chown "$user"."$user" "$homedir"/.rtorrent-session
  74. fi
  75.  
  76.  
  77. if [ ! -d "$homedir"/Downloads ]; then
  78.         mkdir "$homedir"/Downloads
  79.         chown "$user"."$user" "$homedir"/Downloads
  80. else
  81.         chown "$user"."$user" "$homedir"/Downloads
  82. fi
  83.  
  84. echo "# This is an example resource file for rTorrent. Copy to
  85. # ~/.rtorrent.rc and enable/modify the options as needed. Remember to
  86. # uncomment the options you wish to enable.
  87.  
  88. # Maximum and minimum number of peers to connect to per torrent.
  89. #min_peers = 40
  90. #max_peers = 100
  91.  
  92. # Same as above but for seeding completed torrents (-1 = same as downloading)
  93. #min_peers_seed = 10
  94. #max_peers_seed = 50
  95.  
  96. # Maximum number of simultanious uploads per torrent.
  97. #max_uploads = 15
  98.  
  99. # Global upload and download rate in KiB. "0" for unlimited.
  100. #download_rate = 0
  101. #upload_rate = 0
  102.  
  103. # Default directory to save the downloaded torrents.
  104. directory = ~/Downloads
  105.  
  106. # Default session directory. Make sure you don't run multiple instance
  107. # of rtorrent using the same session directory. Perhaps using a
  108. # relative path?
  109. session = ~/.rtorrent-session
  110.  
  111. # Watch a directory for new torrents, and stop those that have been
  112. # deleted.
  113. #schedule = watch_directory,5,5,load_start=./watch/*.torrent
  114. #schedule = untied_directory,5,5,stop_untied=
  115.  
  116. # Close torrents when diskspace is low.
  117. schedule = low_diskspace,5,60,close_low_diskspace=100M
  118.  
  119. # The ip address reported to the tracker.
  120. #ip = 127.0.0.1
  121. #ip = rakshasa.no
  122.  
  123. # The ip address the listening socket and outgoing connections is
  124. # bound to.
  125. #bind = 127.0.0.1
  126. #bind = rakshasa.no
  127.  
  128. # Port range to use for listening.
  129. port_range = 6790-6999
  130.  
  131. # Start opening ports at a random position within the port range.
  132. #port_random = no
  133.  
  134. # Check hash for finished torrents. Might be usefull until the bug is
  135. # fixed that causes lack of diskspace not to be properly reported.
  136. #check_hash = no
  137.  
  138. # Set whetever the client should try to connect to UDP trackers.
  139. #use_udp_trackers = yes
  140.  
  141. # Alternative calls to bind and ip that should handle dynamic ip's.
  142. #schedule = ip_tick,0,1800,ip=rakshasa
  143. #schedule = bind_tick,0,1800,bind=rakshasa
  144.  
  145. # Encryption options, set to none (default) or any combination of the following:
  146. # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
  147. #
  148. # The example value allows incoming encrypted connections, starts unencrypted
  149. # outgoing connections but retries with encryption if they fail, preferring
  150. # plaintext to RC4 encryption after the encrypted handshake
  151. #
  152. encryption = allow_incoming,enable_retry,try_outgoing
  153.  
  154. # Enable DHT support for trackerless torrents or when all trackers are down.
  155. # May be set to "disable" (completely disable DHT), "off" (do not start DHT),
  156. # "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
  157. # The default is "off". For DHT to work, a session directory must be defined.
  158. #
  159. # dht = auto
  160.  
  161. # UDP port to use for DHT.
  162. #
  163. # dht_port = 6881
  164.  
  165. # Enable peer exchange (for torrents not marked private)
  166. #
  167. # peer_exchange = yes
  168.  
  169. #
  170. # Do not modify the following parameters unless you know what you're doing.
  171. #
  172.  
  173. # Hash read-ahead controls how many MB to request the kernel to read
  174. # ahead. If the value is too low the disk may not be fully utilized,
  175. # while if too high the kernel might not be able to keep the read
  176. # pages in memory thus end up trashing.
  177. #hash_read_ahead = 10
  178.  
  179. # Interval between attempts to check the hash, in milliseconds.
  180. #hash_interval = 100
  181.  
  182. # Number of attempts to check the hash while using the mincore status,
  183. # before forcing. Overworked systems might need lower values to get a
  184. # decent hash checking rate.
  185. #hash_max_tries = 10
  186.  
  187. scgi_port = 127.0.0.1:5000" > $homedir/.rtorrent.rc
  188.  
  189. chown "$user"."$user" "$homedir"/.rtorrent.rc
  190.  
  191. if [ -z "$(cat /etc/apache2/apache2.conf | grep 'SCGIMount /RPC2 127.0.0.1:5000')" ]; then
  192. echo "
  193. # rutorrent
  194. SCGIMount /RPC2 127.0.0.1:5000" >> /etc/apache2/apache2.conf
  195. fi
  196.  
  197. if [ ! -h /etc/apache2/mods-enabled/scgi.load ]; then
  198.  
  199.         ln -s /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load
  200. fi
  201.  
  202.  
  203. wget http://rutorrent.googlecode.com/files/rutorrent-3.3.tar.gz
  204. tar -zxvf rutorrent-3.3.tar.gz
  205.  
  206. if [ -d /var/www/rutorrent ]; then
  207.         rm -r /var/www/rutorrent
  208. fi
  209.  
  210. mv -f rutorrent /var/www/
  211. rm -v rutorrent-3.3.tar.gz
  212.  
  213. wget http://rutorrent-tadd-labels.googlecode.com/files/lbll-suite_0.8.1.tar.gz
  214. wget http://rutorrent.googlecode.com/files/data-3.3.tar.gz
  215. wget http://rutorrent.googlecode.com/files/erasedata-3.3.tar.gz
  216. wget http://rutorrent.googlecode.com/files/ratio-3.3.tar.gz
  217. wget http://rutorrent.googlecode.com/files/seedingtime-3.3.tar.gz
  218. wget http://rutorrent.googlecode.com/files/tracklabels-3.3.tar.gz
  219. wget http://srious.biz/nfo.tar.gz
  220.  
  221. tar -zxvf lbll-suite_0.8.1.tar.gz
  222. tar -zxvf data-3.3.tar.gz
  223. tar -zxvf erasedata-3.3.tar.gz
  224. tar -zxvf ratio-3.3.tar.gz
  225. tar -zxvf seedingtime-3.3.tar.gz
  226. tar -zxvf tracklabels-3.3.tar.gz
  227. tar -zxvf nfo.tar.gz                          
  228.  
  229. mv lbll-suite data erasedata ratio seedingtime tracklabels nfo /var/www/rutorrent/plugins
  230. rm lbll-suite_0.8.1.tar.gz data-3.3.tar.gz erasedata-3.3.tar.gz ratio-3.3.tar.gz seedingtime-3.3.tar.gz tracklabels-3.3.tar.gz nfo.tar.gz
  231.  
  232. chown -R www-data.www-data /var/www/rutorrent
  233.  
  234. echo 'AuthUserFile /var/www/rutorrent/.htpasswd
  235. AuthName "Tits or GTFO"
  236. AuthType Basic
  237. Require Valid-User' > /var/www/rutorrent/.htaccess
  238.  
  239. if [ ! -f /etc/apache2/sites-available/rutorrent.script.conf ]; then
  240.  
  241. echo "<VirtualHost *:80>
  242.        ServerName *
  243.        ServerAlias *
  244.  
  245.        DocumentRoot /var/www/
  246.  
  247.        CustomLog /var/log/apache2/rutorrent.log vhost_combined
  248.  
  249.        ErrorLog /var/log/apache2/rutorrent_error.log
  250.  
  251.        <Directory /var/www/rutorrent/>
  252.                Options Indexes FollowSymLinks MultiViews
  253.                AllowOverride AuthConfig
  254.                Order allow,deny
  255.                allow from all
  256.        </Directory>
  257. </VirtualHost>" > /etc/apache2/sites-available/rutorrent.script.conf
  258.  
  259. a2ensite rutorrent.script.conf
  260.  
  261. fi
  262.  
  263. echo -n "Please type the username for the webinterface, system user not required: "
  264. read -e htauser
  265.  
  266. while true; do
  267.  
  268.         htpasswd -c /var/www/rutorrent/.htpasswd "$htauser"
  269.         if [ $? = 0 ]; then
  270.                 break
  271.         fi
  272. done
  273.  
  274. if [ -z "$(crontab -l | grep rtorrent)" ]; then
  275.         cat <(crontab -l) <(echo "@reboot su $user -c 'screen -d -m -U -fa -S rtorrent rtorrent'") | crontab -
  276. fi
  277.  
  278. service apache2 restart
  279.  
  280. echo -e "\033[0;32;148mInstallation is complete..\033[39m"
  281. echo
  282. echo "Starting rtorrent.."
  283.  
  284. su "$user" -c 'screen -d -m -U -fa -S rtorrent rtorrent'
  285.  
  286. echo -e "\033[0;32;148m Done..\033[39m"
  287. echo
  288. echo -e "\033[1;34;148mYour downloads is put in the 'Downloads' folder, sessions data in '.rtorrent-session' and
  289. rtorrent's configuration file is '.rtorrent.rc', all in your home directory.\033[39m"
  290. echo
  291. echo -e "\033[1;34;148mIf you want to change configuration for rtorrent, such as download folder, port, etc.,
  292. you will need to edit the '.rtorrent.rc' file. E.g. 'nano $homedir/.rtorrent.rc'\033[39m"
  293. tput sgr0
  294. echo
  295.  
  296. if [ -z "$(ip addr | grep eth0)" ]; then
  297.         echo "Visit rutorrent at http://IP.ADDRESS/rutorrent"
  298. else
  299.         ip=$(ip addr | grep eth0 | grep inet | awk '{print $2}' | cut -d/ -f1)
  300.         echo "Visit rutorrent at http://$ip/rutorrent"
  301. fi
  302. echo
  303. echo -e "\033[0;32;148mA shout out to NT, the greatest Trac.... Eeeeh... Community in the world!\033[39m"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top