1
0
mirror of https://github.com/elisspace/rtinst.git synced 2026-08-30 08:02:14 +00:00
Files
rtinst/rtupdate
2015-11-08 13:17:06 +00:00

123 lines
3.6 KiB
Bash

#!/bin/bash
######################################################################
#
# Copyright (c) 2015 arakasi72 (https://github.com/arakasi72)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# --> Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
#
######################################################################
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
RTFILE=/usr/local/bin/rt
duoversion="0.13.2/0.9.2 0.13.3/0.9.3 0.13.4/0.9.4 0.13.6/0.9.6"
OSNAME=$(cat /etc/issue.net | cut -d' ' -f1)
installed() {
hash $1 2>/dev/null
}
ask_version() {
while [ -z "$verschoice" ]
do
echo "Please select libtorrent/rtorrent version."
select verschoice in ${duoversion[*]}
do
libvers=$(echo $verschoice | cut -d/ -f1)
rtvers=$(echo $verschoice | cut -d/ -f2)
break
done
done
}
confirm_answer() {
while true
do
read -p "Sure you wish to install libtorrent-"$libvers" and rtorrent-"$rtvers"?" answer
case $answer in [Yy]* ) return 0 ;;
[Nn]* ) exit ;;
* ) echo "Enter y or n";;
esac
done
}
if ! [ "$LOGNAME" = "root" ]; then
echo "Must be run as root, or with sudo"
exit 1
fi
if ( installed rtorrent ); then
echo "rtorrent detected"
echo
else
echo "rtorrent NOT installed"
echo "This script is for upgrading/downgrading only, not for initial install"
exit 1
fi
ask_version
confirm_answer
echo
echo "Installing $libvers/$rtvers"
cd $HOME
rtgetscripts
if [ -d source ]; then
cd source
else
mkdir source && cd source
fi
rm -r libtorrent* rtorrent*
echo "Fetching source files"
curl -# http://rtorrent.net/downloads/libtorrent-$libvers.tar.gz | tar xz
curl -# http://rtorrent.net/downloads/rtorrent-$rtvers.tar.gz | tar xz
echo "Compiling libtorrent"
cd $HOME/source/libtorrent-$libvers
./autogen.sh >> /dev/null 2>&1
if [ $OSNAME = "Raspbian" ]; then
./configure --prefix=/usr --disable-instrumentation >> /dev/null 2>&1
else
./configure --prefix=/usr >> /dev/null 2>&1
fi
make -j2 >> /dev/null 2>&1
make install >> /dev/null 2>&1
echo "Compiling rtorrent"
cd $HOME/source/rtorrent-$rtvers
./autogen.sh >> /dev/null 2>&1
./configure --prefix=/usr --with-xmlrpc-c >> /dev/null 2>&1
make -j2 >> /dev/null 2>&1
make install >> /dev/null 2>&1
ldconfig
cd /var/www/rutorrent/conf/users
user_list=*
for user in $user_list
do
echo "Restarting rtorrent for $user"
su $user -c 'rt restart >> /dev/null 2>&1'
done
cd $HOME
echo
echo "$libvers/$rtvers installed"
echo
echo "Your .rtorrent.rc file, and download, watch, and .session directories have not been altered in any way"