forked from arakasi72/rtinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtupdate
118 lines (95 loc) · 2.59 KB
/
rtupdate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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
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
if [ ! $user = '*' ]; then
echo "Restarting rtorrent for $user"
su $user -c 'rt restart >> /dev/null 2>&1'
fi
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"