mirror of
https://github.com/elisspace/rtinst.git
synced 2026-08-30 08:02:14 +00:00
133 lines
3.0 KiB
Bash
133 lines
3.0 KiB
Bash
#!/bin/bash
|
|
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
|
|
RTFILE=/usr/local/bin/rt
|
|
home="/home/$SUDO_USER"
|
|
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"
|
|
FULLREL=$(cat /etc/issue.net)
|
|
RELNO='0'
|
|
|
|
installed() {
|
|
hash $1 2>/dev/null
|
|
}
|
|
|
|
get_scripts() {
|
|
local script_name=$1
|
|
local script_dest=$2
|
|
local no_err=1
|
|
local attempts=0
|
|
until [ $no_err = 0 ]
|
|
do
|
|
rm -f $script_name
|
|
wget --no-check-certificate https://raw.githubusercontent.com/arakasi72/rtinst/master/$script_name
|
|
no_err=$?
|
|
attempts=$(( $attempts + 1 ))
|
|
if [ $attempts = 20 ]; then
|
|
echo "There is a problem downloading the scripts. Please check your network or there may be an issue with the github website"
|
|
echo "If the Github website is down, you can try again later"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
if ! [ -z "$script_dest" ]; then
|
|
mv -f $script_name $script_dest
|
|
fi
|
|
}
|
|
|
|
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 [ -z "$SUDO_USER" -o "$SUDO_USER" = "root" ]; then
|
|
echo "Must be run using sudo"
|
|
exit
|
|
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
|
|
test "${FULLREL#*Raspbian GNU/Linux 7}" != "$FULLREL" && RELNO="RPi"
|
|
|
|
echo
|
|
echo "Installing $libvers/$rtvers"
|
|
|
|
if ! [ -x $RTFILE ]; then
|
|
get_scripts rt /usr/local/bin/rt
|
|
fi
|
|
|
|
cd $home
|
|
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 [ $RELNO = "RPi" ]; 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"
|