mirror of
https://github.com/elisspace/rtinst.git
synced 2026-08-30 16:12:12 +00:00
* Update rtupdate * Update rtupdate * Update rtupdate * Update rtupdate * Update rtupdate * Update rtupdate * Update rtupdate * Update rtinst * Update rtupdate * Update rtupdate * Update rtinst * Update rtupdate * Update rtinst * Update rtupdate * Update rtupdate * Update rtupdate * Update rtinst
174 lines
4.7 KiB
Bash
Executable File
174 lines
4.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
######################################################################
|
|
#
|
|
# Copyright (c) 2015 arakasi72 (https://github.com/arakasi72)
|
|
#
|
|
# --> 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
|
|
|
|
sourcedir='http://rtorrent.net/downloads/'
|
|
xmlrpcloc='https://svn.code.sf.net/p/xmlrpc-c/code/stable'
|
|
osname=$(lsb_release -si)
|
|
relno=$(lsb_release -sr | cut -d. -f1)
|
|
listsize=6
|
|
duoversion=''
|
|
logfile="/dev/null"
|
|
passed_rtvers=$1
|
|
|
|
rt_releases=$(wget -q -O - $sourcedir | grep -o "rtorrent-[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}\.tar.gz" | sort -uV | tail -$listsize | grep -o "[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}")
|
|
|
|
for rtversion in $rt_releases
|
|
do
|
|
libversion=$(echo $rtversion | awk -F. -v OFS=. '{$2='$(( $(echo $rtversion | cut -d. -f2) + 4 ))'; print }')
|
|
duoversion="$duoversion $libversion/$rtversion"
|
|
done
|
|
|
|
latest_duo=$(echo $duoversion | rev | cut -d' ' -f1 | rev)
|
|
latest_libvers=$(echo $latest_duo | cut -d/ -f1)
|
|
latest_rtvers=$(echo $latest_duo | cut -d/ -f2)
|
|
|
|
installed() {
|
|
hash $1 2>/dev/null
|
|
}
|
|
|
|
list_version() {
|
|
local verschoice
|
|
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
|
|
}
|
|
|
|
ask_user(){
|
|
local answer
|
|
while true
|
|
do
|
|
read answer
|
|
case $answer in [Yy]* ) return 0 ;;
|
|
[Nn]* ) return 1 ;;
|
|
* ) echo "Enter y or n";;
|
|
esac
|
|
done
|
|
}
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "Must be run as root, or with sudo"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z $passed_rtvers ]; then
|
|
if ( installed rtorrent ); then
|
|
rtorrent_current=$(rtorrent -h | grep -m 1 'version')
|
|
rtorrent_current=${rtorrent_current#*version }
|
|
echo "rtorrent $rtorrent_current detected"
|
|
cd $HOME
|
|
else
|
|
echo "rtorrent NOT installed"
|
|
echo "This script is for upgrading/downgrading only, not for initial install"
|
|
exit 1
|
|
fi
|
|
if [ $relno -eq 9 ]; then
|
|
libvers='0.13.6'
|
|
rtvers='0.9.6'
|
|
echo "Debian 9 is only supported by libtorrent-0.13.6/rtorrent-0.9.6"
|
|
else
|
|
list_version
|
|
fi
|
|
|
|
echo "Install libtorrent-$libvers and rtorrent-$rtvers"
|
|
echo "Your rtorrent config, torrents, and data will not be lost or changed"
|
|
echo -n "Continue? "
|
|
if ! ask_user; then
|
|
exit
|
|
fi
|
|
else
|
|
if [ "$passed_rtvers" = "latest" ] || [ $(wget -q -O - $sourcedir | grep -o "rtorrent-$passed_rtvers.tar.gz" | wc -l) -eq 0 ]; then
|
|
if [ "$passed_rtvers" != "latest" ]; then
|
|
echo " Could not find $passed_rtvers so using latest version instead"
|
|
fi
|
|
libvers=$latest_libvers
|
|
rtvers=$latest_rtvers
|
|
else
|
|
libvers=$(echo $passed_rtvers | awk -F. -v OFS=. '{$2='$(( $(echo $rtversion | cut -d. -f2) + 4 ))'; print }')
|
|
rtvers=$passed_rtvers
|
|
fi
|
|
|
|
if [ $relno -eq 9 ]; then
|
|
libvers='0.13.6'
|
|
rtvers='0.9.6'
|
|
echo "Debian 9 is only supported by libtorrent-0.13.6/rtorrent-0.9.6"
|
|
fi
|
|
|
|
fi
|
|
|
|
echo
|
|
echo "Installing libtorrent-$libvers/rtorrent-$rtvers"
|
|
|
|
if [ -d source ]; then
|
|
cd source
|
|
else
|
|
mkdir source && cd source
|
|
fi
|
|
rm -rf xmlrpc libtorrent* rtorrent*
|
|
|
|
echo "Fetching source files"
|
|
svn co $xmlrpcloc xmlrpc >> $logfile 2>&1
|
|
|
|
if [ $relno -eq 9 ]; then
|
|
git clone -q -b feature-bind --single-branch https://github.com/rakshasa/libtorrent.git libtorrent-$libvers
|
|
git clone -q -b feature-bind --single-branch https://github.com/rakshasa/rtorrent.git rtorrent-$rtvers
|
|
else
|
|
curl -# http://rtorrent.net/downloads/libtorrent-$libvers.tar.gz | tar xz
|
|
curl -# http://rtorrent.net/downloads/rtorrent-$rtvers.tar.gz | tar xz
|
|
fi
|
|
|
|
cd xmlrpc
|
|
echo "Installing xmlrpc" | tee -a $logfile
|
|
./configure --prefix=/usr --disable-cplusplus >> $logfile 2>&1
|
|
make >> $logfile 2>&1
|
|
make install >> $logfile 2>&1
|
|
|
|
cd ../libtorrent-$libvers
|
|
echo "Installing libtorrent" | tee -a $logfile
|
|
./autogen.sh >> $logfile 2>&1
|
|
if [ $osname = "Raspbian" ]; then
|
|
./configure --prefix=/usr --disable-instrumentation >> $logfile 2>&1
|
|
else
|
|
./configure --prefix=/usr >> $logfile 2>&1
|
|
fi
|
|
make -j2 >> $logfile 2>&1
|
|
make install >> $logfile 2>&1
|
|
|
|
cd ../rtorrent-$rtvers
|
|
echo "Installing rtorrent" | tee -a $logfile
|
|
./autogen.sh >> $logfile 2>&1
|
|
./configure --prefix=/usr --with-xmlrpc-c >> $logfile 2>&1
|
|
make -j2 >> $logfile 2>&1
|
|
make install >> $logfile 2>&1
|
|
ldconfig >> $logfile 2>&1
|
|
|
|
echo "$libvers/$rtvers installed"
|
|
echo
|
|
|
|
if [ -d /var/www/rutorrent/conf/users ]; then
|
|
cd /var/www/rutorrent/conf/users
|
|
user_list=*
|
|
for user in $user_list; do
|
|
if [ ! "$user" = '*' ]; then
|
|
echo "Restarting rtorrent for $user"
|
|
su $user -c 'rt restart >> /dev/null 2>&1'
|
|
fi
|
|
done
|
|
echo
|
|
fi
|