This repository was archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpm.sh
184 lines (148 loc) · 5.25 KB
/
rpm.sh
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this script!"
exit 1
fi
TRANS_PATH=`pwd`
if [ `echo $TRANS_PATH | awk -F/ '{print $NF}'` != "trans" ]; then
clear && echo "Please enter trans script path:"
read -p "(Default path: ${TRANS_PATH}/trans):" TRANS_PATH
[ -z "$TRANS_PATH" ] && TRANS_PATH=$(pwd)/trans
cd $TRANS_PATH/
fi
clear
echo "#############################################################"
echo "# Transmission Auto Install Shell Script"
echo "# Env: Redhat/CentOS"
echo "# Intro: http://wangyan.org/blog/transmission.html"
echo "# Version: $(awk '/version/{print $2}' $TRANS_PATH/Changelog)"
echo "#"
echo "# Copyright (c) 2012, WangYan <WangYan@188.com>"
echo "# All rights reserved."
echo "# Distributed under the GNU General Public License, version 3.0."
echo "#"
echo "#############################################################"
echo ""
echo "Please enter remote login username:"
read -p "(Default username: demo):" USERNAME
if [ -z $USERNAME ]; then
USERNAME="demo"
fi
echo "---------------------------"
echo "login username = $USERNAME"
echo "---------------------------"
echo ""
echo "Please enter remote login password:"
read -p "(Default password: demo):" PASSWORD
if [ -z $PASSWORD ]; then
PASSWORD="demo"
fi
echo "---------------------------"
echo "login password = $PASSWORD"
echo "---------------------------"
echo ""
echo "Please enter the download dir:"
read -p "(Default download dir: /root/Downloads):" DLDIR
if [ -z $DLDIR ]; then
DLDIR="/root/Downloads"
fi
echo "---------------------------"
echo "download dir=$DLDIR"
echo "---------------------------"
echo ""
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo "Press any key to start install..."
echo ""
char=`get_char`
echo "---------- Disable SeLinux ----------"
if [ -s /etc/selinux/config ]; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
fi
echo "---------- Set Library ----------"
if [ ! `grep -iqw /lib /etc/ld.so.conf` ]; then
echo "/lib" >> /etc/ld.so.conf
fi
if [ ! `grep -iqw /usr/lib /etc/ld.so.conf` ]; then
echo "/usr/lib" >> /etc/ld.so.conf
fi
if [ -d "/usr/lib64" ] && [ ! `grep -iqw /usr/lib64 /etc/ld.so.conf` ]; then
echo "/usr/lib64" >> /etc/ld.so.conf
fi
if [ ! `grep -iqw /usr/local/lib /etc/ld.so.conf` ]; then
echo "/usr/local/lib" >> /etc/ld.so.conf
fi
echo "---------- Dependent Packages ----------"
yum -y install gcc gcc-c++ m4 make automake libtool gettext openssl-devel pkgconfig curl curl-devel intltool
echo "================ Transmission Install ==============="
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
echo "---------- libevent ----------"
if [ ! -s libevent-*.tar.gz ]; then
wget -c https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
fi
tar -zxf libevent-*.tar.gz
cd libevent-*
./configure
make && make install && ldconfig
echo "---------- libiconv ----------"
cd $TRANS_PATH/
if [ ! -s libiconv-*.tar.gz ]; then
wget -c http://src-mirror.googlecode.com/files/libiconv-1.14.tar.gz
fi
tar -zxf libiconv-*.tar.gz
cd libiconv-*/
./configure --prefix=/usr/local
make && make install && ldconfig
echo "---------- transmission ----------"
cd $TRANS_PATH/
if [ ! -s transmission-*.tar.bz2 ]; then
wget -c http://download.transmissionbt.com/files/transmission-2.71.tar.bz2
fi
tar -jxf transmission-*.tar.bz2
cd transmission-*
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
./configure --prefix=/usr/local/transmission CFLAGS=-liconv
else
./configure --prefix=/usr/local/transmission
fi
make && make install
echo "---------- transmission config ----------"
for i in `ls /usr/local/transmission/bin/`; do ln -s /usr/local/transmission/bin/$i /usr/bin/$i; done
cp $TRANS_PATH/init.d.transmission /etc/init.d/transmission
chmod 755 /etc/init.d/transmission
#chkconfig transmission on
mkdir -p $DLDIR > /dev/null 2>&1
mkdir -p /usr/local/transmission/etc/
/etc/init.d/transmission start > /dev/null 2>&1
sed -i 's/240/512/g' /usr/local/transmission/etc/settings.json
sed -i 's/60/128/g' /usr/local/transmission/etc/settings.json
sed -i 's#/root/Downloads#'$DLDIR'#g' /usr/local/transmission/etc/settings.json
sed -i 's/^.*rpc-authentication-required.*/"rpc-authentication-required": true,/' /usr/local/transmission/etc/settings.json
sed -i 's/^.*rpc-password.*/"rpc-password": "'$PASSWORD'",/' /usr/local/transmission/etc/settings.json
sed -i 's/^.*rpc-username.*/"rpc-username": "'$USERNAME'",/' /usr/local/transmission/etc/settings.json
sed -i 's/^.*rpc-whitelist-enabled.*/"rpc-whitelist-enabled": false,/' /usr/local/transmission/etc/settings.json
\cp /usr/local/transmission/etc/settings.json /usr/local/transmission/etc/settings.json.bak
/etc/init.d/transmission restart
service iptables stop > /dev/null 2>&1
clear
echo ""
echo "===================== Install completed ====================="
echo ""
echo "Transmission install completed!"
echo "Intro http://wangyan.org/blog/transmission.html"
echo ""
echo "Transmission Config: /usr/local/transmission/etc/settings.json.bak"
echo "Transmission Web Url: http://IP_ADDRESS:9091"
echo ""
echo "============================================================="
echo ""