#!/bin/bash PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin chkans=0 SERVERIP=$(ip a s eth0 | awk '/inet / {print$2}' | cut -d/ -f1) RTFILE=/usr/local/bin/rt installed() { hash $1 2>/dev/null } ask_version() { while true do echo "Select version to upgrade/downgrade to" echo "1. libtorrent 0.13.2/rtorrent 0.9.2" echo "2. libtorrent 0.13.3/rtorrent 0.9.3" echo "3. libtorrent 0.13.4/rtorrent 0.9.4" echo "4. Quit" read -p "Select an option " answer case $answer in [1] ) libvers="libtorrent-0.13.2" && rtvers="rtorrent-0.9.2" && return 0 ;; [2] ) libvers="libtorrent-0.13.3" && rtvers="rtorrent-0.9.3" && return 0 ;; [3] ) libvers="libtorrent-0.13.4" && rtvers="rtorrent-0.9.4" && return 0 ;; [4] ) exit ;; * ) echo "Enter 1-4";; esac done } confirm_answer() { while true do read -p "Sure you wish to install $libvers/$rtvers? " answer case $answer in [Yy]* ) chkans=1 && return 0 ;; [Nn]* ) return 0 ;; * ) echo "Enter y or n";; esac done } if ( installed rtorrent ) then sudo echo "rtorrent detected" echo else echo "rtorrent NOT installed" echo "This script is for upgrading/downgrading only, not for initial install" exit 1 fi while [ $chkans = 0 ] do ask_version confirm_answer done echo echo "Installing $libvers/$rtvers" if ! [ -x $RTFILE ] then sudo wget --no-check-certificate https://raw.githubusercontent.com/arakasi72/rtinst/master/rt -O /usr/local/bin/rt && sudo chmod 755 /usr/local/bin/rt fi crontab -l | perl -nle 's/^([^#@])/# $1/;print' | crontab rt stop cd source #svn co https://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc curl http://libtorrent.rakshasa.no/downloads/$libvers.tar.gz | tar xz curl http://libtorrent.rakshasa.no/downloads/$rtvers.tar.gz | tar xz #cd xmlrpc #./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server #make #sudo make install cd ~/source/$libvers ./autogen.sh ./configure --prefix=/usr make -j2 sudo make install cd ~/source/$rtvers ./autogen.sh ./configure --prefix=/usr --with-xmlrpc-c make -j2 sudo make install sudo ldconfig rt start crontab -l | perl -nle 's/^#\s*([0-9*])/$1/;print' | crontab echo echo "$libvers/$rtvers installed" echo echo "Confirm at https://$SERVERIP/rutorrent" echo echo "Your .rtorrent.rc file, and download, watch, and .session directories have not been altered in any way"