#!/bin/sh echo "Don't forget to update this script with the change-log! Press ENTER to start..." read NAME="rtorrent" VERSION="0.8.9" SOURCE="http://libtorrent.rakshasa.no/downloads/rtorrent-$VERSION.tar.gz" CONFIGURE="--prefix=/usr/local --disable-debug --with-xmlrpc-c" DATE=`date '+%Y/%m/%d'` SCRIPT_NAME=$(basename $0) cp $0 /tmp/ export CFLAGS="-march=i486 -mtune=i686 -Os -pipe" export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe" export LDFLAGS="-Wl,-O1" echo "Downloading essential packages..." tce-load -wi compiletc squashfs-tools-4.x ncurses ncurses-dev curl curl-dev openssl-1.0.0 openssl-1.0.0-dev libsigc++ libsigc++-dev libssh2 libssh2-dev cd /tmp/ # Uncomment the one you would like to use: # Install libtorrent from the repo: tce-load -wi libtorrent-dev libtorrent # Or install libxmlrpc from /tmp/ local directory (if you have just built these packages) tce-load -i libxmlrpc-dev libxmlrpc wget $SOURCE sudo rm -rf $NAME-$VERSION 2>/dev/null sudo rm /tmp/$NAME.tcz /tmp/$NAME.tcz.list /tmp/$NAME.tcz.md5.txt /tmp/$NAME.tcz.dep 2>/dev/null sudo rm -rf /tmp/$NAME 2>/dev/null sudo rm /tmp/$NAME-doc.tcz /tmp/$NAME-doc.tcz.list /tmp/$NAME-doc.tcz.md5.txt /tmp/$NAME-doc.tcz.dep 2>/dev/null sudo rm -rf /tmp/$NAME-doc 2>/dev/null tar xvfz $NAME-$VERSION.tar.gz cd $NAME-$VERSION echo " Starting ./configure $CONFIGURE" ./configure $CONFIGURE echo "Press ENTER to continue... " read make -j3 echo " Starting make install to: /tmp/$NAME" sudo make DESTDIR=/tmp/$NAME install-strip cd /tmp/$NAME sudo find . | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null sudo find . | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null sudo mkdir -p /tmp/$NAME/usr/local/etc/init.d sudo echo "# Maximum and minimum number of peers to connect to per torrent. #min_peers = 40 max_peers = 250 # Same as above but for seeding completed torrents (-1 = same as downloading) #min_peers_seed = 10 max_peers_seed = 150 # Maximum number of simultanious uploads per torrent. max_uploads = 15 # Set the max amount of memory space used to mapping file chunks. #max_memory_usage = 512000000 # Global upload and download rate in KiB. \"0\" for unlimited. download_rate = 0 upload_rate = 0 # File creation mask umask = 0000 # The rtorrent doesn't list the active tab properly by default. Add this fix: schedule = filter_active,30,30,\"view_filter = active,\\\"or={d.get_up_rate=,d.get_down_rate=}\\\"\" # Close torrents when diskspace is low. schedule = low_diskspace,5,60,close_low_diskspace=50M # Max number of files to keep open simultaniously. #max_open_files = 128 # Number of sockets to simultaneously keep open. #max_open_sockets = # IP and Port range to use for listening. #ip = 127.0.0.1 port_range = 59000-59500 # Alternative calls to bind and ip that should handle dynamic ip's. #schedule = ip_tick,0,1800,ip=rakshasa #schedule = bind_tick,0,1800,bind=rakshasa # Start opening ports at a random position within the port range. port_random = no # Example of scheduling commands: Switch between two ip's every 5 seconds. #schedule = \"ip_tick1,5,10,ip=torretta\" #schedule = \"ip_tick2,10,10,ip=lampedusa\" # Remove a scheduled event. #schedule_remove = \"ip_tick1\" # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a relative path? session = /home/tc/.session/ # If you want to use rTorrent with a WebGUI (for example: ruTorrent) you need to uncomment one of the following: (you also need to configure in ruTorrent's config.php to either use 'port' or 'local unix socket' method for communicating with rTorrent) #scgi_port = localhost:5000 #scgi_local = /home/tc/.session/scgi.socket # Set http proxy if you are behing one. #http_proxy = url # Set whetever the client should try to connect to UDP trackers. use_udp_trackers = yes # Check hash for finished torrents. Might be useful until the bug is # fixed that causes lack of diskspace not to be properly reported. check_hash = yes # Hash read-ahead controls how many MB to request the kernel to read # ahead. If the value is too low the disk may not be fully utilized, # while if too high the kernel might not be able to keep the read # pages in memory thus end up trashing. hash_read_ahead = 10 # Interval between attempts to check the hash, in milliseconds. hash_interval = 100 # Number of attempts to check the hash while using the mincore status, # before forcing. Overworked systems might need lower values to get a # decent hash checking rate. hash_max_tries = 5 # Stop torrents when reaching upload ratio in percent, # when also reaching total upload in bytes, or when # reaching final upload ratio in percent. # example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0 #schedule = ratio,60,60,stop_on_ratio=200,200M,2000 # Encryption options, set to none (default) or any combination of the following: # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext # # The example value allows incoming encrypted connections, starts unencrypted # outgoing connections but retries with encryption if they fail, preferring # plaintext to RC4 encryption after the encrypted handshake # # encryption = allow_incoming,enable_retry,prefer_plaintext encryption = allow_incoming,try_outgoing,enable_retry # Enable DHT support for trackerless torrents or when all trackers are down. # May be set to \"disable\" (completely disable DHT), \"off\" (do not start DHT), # \"auto\" (start and stop DHT as needed), or \"on\" (start DHT immediately). # The default is \"off\". For DHT to work, a session directory must be defined. dht = auto # UDP port to use for DHT. dht_port = 6881 # Enable peer exchange (for torrents not marked private) #peer_exchange = yes # Log file #log.execute = /var/log/rtorrent.exec # Location where new torrent data is placed, and where you should place your # 'complete' data before you place your *.torrent file into the watch folder. directory = /mnt/your_partition/torrent_incomplete # Watch directory_1 schedule = watch_directory_1,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_general/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_general,d.delete_tied=\" system.method.insert=checkdirs1,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck1,simple,\"and={checkdirs1=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir1,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed1,\"branch={$movecheck1=,movedir1=}\" # Watch directory_2 schedule = watch_directory_2,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_games/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_games,d.delete_tied=\" system.method.insert=checkdirs2,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck2,simple,\"and={checkdirs2=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir2,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed2,\"branch={$movecheck2=,movedir2=}\" # Watch directory_3 schedule = watch_directory_3,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_video/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_video,d.delete_tied=\" system.method.insert=checkdirs3,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck3,simple,\"and={checkdirs3=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir3,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed3,\"branch={$movecheck3=,movedir3=}\" # Watch directory_4 schedule = watch_directory_4,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_music/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_music,d.delete_tied=\" system.method.insert=checkdirs4,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck4,simple,\"and={checkdirs4=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir4,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed4,\"branch={$movecheck4=,movedir4=}\" # Watch directory_5 schedule = watch_directory_5,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_watchdir5/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_watchdir5,d.delete_tied=\" system.method.insert=checkdirs5,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck5,simple,\"and={checkdirs5=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir5,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed5,\"branch={$movecheck5=,movedir5=}\" # Watch directory_6 schedule = watch_directory_6,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_watchdir6/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_watchdir6,d.delete_tied=\" system.method.insert=checkdirs6,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck6,simple,\"and={checkdirs6=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir6,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed6,\"branch={$movecheck6=,movedir6=}\" # Watch directory_7 schedule = watch_directory_7,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_watchdir7/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_watchdir7,d.delete_tied=\" system.method.insert=checkdirs7,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck7,simple,\"and={checkdirs7=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir7,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed7,\"branch={$movecheck7=,movedir7=}\" # Watch directory_8 schedule = watch_directory_8,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_watchdir8/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_watchdir8,d.delete_tied=\" system.method.insert=checkdirs8,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck8,simple,\"and={checkdirs8=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir8,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed8,\"branch={$movecheck8=,movedir8=}\" # Watch directory_9 schedule = watch_directory_9,5,5,\"load_start=/mnt/your_partition/torrent_watchdir_watchdir9/*.torrent,d.set_custom1=/mnt/your_partition/torrent_complete_watchdir9,d.delete_tied=\" system.method.insert=checkdirs9,simple,\"not=\\\"$equal={d.get_custom1=,d.get_base_path=}\\\"\" system.method.insert=movecheck9,simple,\"and={checkdirs9=,d.get_complete=,d.get_custom1=}\" system.method.insert=movedir9,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" system.method.set_key=event.download.hash_done,move_hashed9,\"branch={$movecheck9=,movedir9=}\" ############################## # How watch directories work # ############################## # schedule a timer event named 'watch_directory_1': # 1) triggers 5 seconds after rtorrent starts # 2) triggers at 5 second intervals thereafter # 3) Upon trigger, attempt to load (and start) new *.torrent files found in /home/tc/torrents/watch/ # 4) set a variable named 'custom1' with the value of the directory where the data will be moved when finished downloading # NOTE: if you don't want it to automatically start the torrent, change 'load_start' to 'load' # insert a method with the alias 'checkdirs1' # 1) returns true if the current path of the torrent data is not equal to the value of custom1 (if it has already been moved) # 2) otherwise, returns false # insert a method with the alias 'movecheck1' # 1) returns true if all 3 commands return true ('result of checkdirs1' && 'torrent is 100% done', 'custom1 variable is set') # 2) otherwise, returns false # insert a method with the alias 'movedir1' # (a series of commands, separated by ';') # 1) \"set path of torrent to equal the value of custom1\"; # 2) \"mv -u \"; # 3) \"clear custom1\", \"stop the torrent\",\"resume the torrent\" # 4) stop the torrent # 5) start the torrent (to get the torrent to update the 'base path') # set a key with the name 'move_hashed1' that is triggered by the hash_done event. # 1) When hashing of a torrent completes, this custom key will be triggered. # 2) when triggered, execute the 'movecheck1' method and check the return value. # 3) if the 'movecheck' method returns 'true', execute the 'movedir1' method we inserted above. # NOTE: 'branch' is an 'if' conditional statement: if(movecheck1){movedir1} # Watch a directory for new torrents, and stop those that have been deleted. #schedule = watch_directory,5,5,load_start=./watch/*.torrent #schedule = untied_directory,5,5,stop_untied= #schedule = watch_directory,5,5,load_start=/home/tc/watch/*.torrent #schedule = untied_directory,5,5,stop_untied= #schedule = tied_directory,5,5,start_tied=" > /tmp/rtorrent.rc sudo mv /tmp/rtorrent.rc /tmp/$NAME/usr/local/etc/.rtorrent.rc sudo echo "#!/bin/sh case \$1 in start) if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq 0 ]; then echo -n \" - Starting rtorrent... \" rm /home/tc/.session/scgi.socket 2>/dev/null su tc -c 'screen -T xterm -d -m -S rtorrent rtorrent' &> /dev/null sleep 3 COUNTER=0 while [ \$COUNTER -lt 10 ]; do if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq \"0\" ]; then echo -n \".\" let COUNTER=COUNTER+1 rm /home/tc/.session/rtorrent.lock 2>/dev/null rm /home/tc/.session/scgi.socket 2>/dev/null su tc -c 'screen -T xterm -d -m -S rtorrent rtorrent' sleep 4 else COUNTER=10 fi done if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq 0 ]; then echo \"Failed to start\" 1>&2 exit 1 else echo \"OK\" fi else echo \" - rtorrent is already running...\" fi ;; stop) if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq 0 ]; then echo \" - rtorrent is not running...\" else echo -n \" - Stopping rtorrent... \" kill -INT \`ps|grep rtorrent|egrep -vi \"grep|screen|etc\"|sed -e 's/^[ \t]*//'|cut -d\" \" -f1\` 2>/dev/null COUNTER=0 while [ \$COUNTER -lt 30 -a \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -gt 0 ]; do sleep 0.5 let COUNTER=COUNTER+1 done kill -TERM \`ps|grep rtorrent|egrep -vi \"grep|screen|etc\"|sed -e 's/^[ \t]*//'|cut -d\" \" -f1\` 2>/dev/null while [ \$COUNTER -lt 20 -a \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -gt 0 ]; do sleep 0.5 let COUNTER=COUNTER+1 done if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq \"0\" ]; then echo \"OK\" else killall -KILL rtorrent 2>/dev/null sleep 1 if [ \`ps|grep rtorrent|egrep -vic \"grep|screen|etc\"\` -eq \"0\" ]; then echo \"OK (killed)\" else echo \"Failed to stop\" 1>&2 exit 1 fi fi fi ;; restart) \$0 stop \$0 start ;; *) echo \"usage: \$0 {start|stop|restart}\" esac exit 0" > /tmp/rtorrent-init sudo chmod +x /tmp/rtorrent-init sudo mv /tmp/rtorrent-init /tmp/$NAME/usr/local/etc/init.d/rtorrent mkdir -p /tmp/$NAME-doc/usr/local/share/man/man1 sudo cp /tmp/$NAME-$VERSION/doc/rtorrent.1 /tmp/$NAME-doc/usr/local/share/man/man1/rtorrent.1 echo "Creating package..." cd /tmp/ sudo mksquashfs $NAME $NAME.tcz sudo md5sum $NAME.tcz > $NAME.tcz.md5.txt cd $NAME sudo find usr -not -type d > ../$NAME.tcz.list cd /tmp/ SIZE="`du -k $NAME.tcz|cut -f1`k" sudo echo "Title: $NAME.tcz Description: rTorrent Version: $VERSION Author: Jari Sundell Original-site: http://libtorrent.rakshasa.no/ Copying-policy: GPL Size: $SIZE Extension_by: andriscom Comments: LibTorrent is a BitTorrent library written in C++ for *nix, with a focus on high performance and good code. The library differentiates itself from other implementations by transfering directly from file pages to the network stack. On high-bandwidth connections it is able to seed at 3 times the speed of the official client. The client uses ncurses and is ideal for use with screen or dtach. It supports saving of sessions and allows the user to add and remove torrents. Built with CFLAGS: -march=i486 -mtune=i686 -Os -pipe Built with CXXFLAGS: -march=i486 -mtune=i686 -Os -pipe Built with LDFLAGS: -Wl,-O1 Built with the following options: ./configure $CONFIGURE You should move the /usr/local/etc/.rtorrent.rc config file to your home directory! Check the configuration and create the proper directories! (/home/tc/.session for example) If you would like to use a WebUI: Download ruTorrent via svn: cd /usr/local/var/www/ svn co http://rutorrent.googlecode.com/svn/trunk/rutorrent cd /usr/local/var/www/rutorrent/ rmdir plugins svn co http://rutorrent.googlecode.com/svn/trunk/plugins/ Uncomment line: scgi_port or scgi_local .rtorrent.rc ruTorrent's config.php also need be configured to either use 'port' or 'local unix socket' connection method You also need to configure your webserver: http://code.google.com/p/rutorrent/wiki/WebSERVER To control rTorrent you can use the /usr/local/etc/init.d/rtorrent script. You will need to install the screen.tcz optional extension to use the init script. For man entries you can install the $NAME-doc.tcz package or visit: http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.htm Source: $SOURCE Change-log: 2010/09/28 First version (0.8.6) 2010/10/06 Version: 0.8.6 - Added: CFLAGS, CXXFLAGS, LDFLAGS, canvas-fix.patch, equal-operator.patch Current: $DATE Version: $VERSION - Removed: canvas-fix.patch, equal-operator.patch " > $NAME.tcz.info sudo echo "ncurses.tcz curl.tcz openssl-1.0.0.tcz libsigc++.tcz libtorrent.tcz libssh2.tcz libxmlrpc.tcz " > $NAME.tcz.dep echo "Creating package..." cd /tmp/ sudo mksquashfs $NAME-doc $NAME-doc.tcz sudo md5sum $NAME-doc.tcz > $NAME-doc.tcz.md5.txt cd $NAME-doc sudo find usr -not -type d > ../$NAME-doc.tcz.list cd /tmp/ SIZE="`du -k $NAME-doc.tcz|cut -f1`k" sudo echo "Title: $NAME-doc.tcz Description: rTorrent man pages Version: $VERSION Author: Jari Sundell Original-site: http://libtorrent.rakshasa.no/ Copying-policy: GPL Size: $SIZE Extension_by: andriscom Comments: Manual entry files for rTorrent $VERSION. Source: $SOURCE Change-log: 2010/09/28 First version (0.8.6) 2010/10/06 Version: 0.8.6 - Added: CFLAGS, CXXFLAGS, LDFLAGS, canvas-fix.patch, equal-operator.patch Current: $DATE Version: $VERSION " > $NAME-doc.tcz.info cd /tmp/ mkdir packages 2>/dev/null sudo rm packages/$NAME.tar.gz 2>/dev/null tar zcf packages/$NAME.tar.gz $NAME.tcz* $NAME-doc.tcz* $SCRIPT_NAME echo " Run bcrypt on /tmp/packages/*.tar.gz... give password: tinycore" echo "Run the extension_audit.sh and reboot a clean system to try the packages!" echo "Send it to: tcesubmit@gmail.com"