-
Notifications
You must be signed in to change notification settings - Fork 23
/
porttraninstall.sh
194 lines (189 loc) · 5.41 KB
/
porttraninstall.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
185
186
187
188
189
190
191
192
193
194
#bin
version='7.0.1.5'
shell_version='2.3.0'
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
myFile=$version.tar.gz
installfolder='/etc/porttran'
if [ ! -f "$myFile" ]; then
echo "\n"
else
rm $version.tar.gz
fi
kill_porttran(){
PROCESS=`ps -ef|grep porttran|grep -v grep|grep -v PPID|awk '{ print $2}'`
for i in $PROCESS
do
echo "Kill the $1 process [ $i ]"
kill -9 $i
done
}
kill_ppexec(){
PROCESS=`ps -ef|grep ppexec|grep -v grep|grep -v PPID|awk '{ print $2}'`
for i in $PROCESS
do
echo "Kill the $1 process [ $i ]"
kill -9 $i
done
}
install() {
wget http://download.transitpool.org/porttraninstall/$version.tar.gz
tar -zxvf $version.tar.gz
cd porttran-$version/porttranpay
tar -zxvf porttranlatest.tar.gz
cd ../..
mv porttran-$version/porttranpay/porttran/portdir.sh porttran-$version/porttranpay/porttran/porttran
mkdir porttran && chmod 777 porttran
mv porttran-$version/porttranpay/porttran/* porttran
cd porttran/ && chmod +x porttran && chmod +x ppexec
cd ../
rm -rf porttran-$version
rm $version.tar.gz
rm porttranfree.sh
cp -r porttran /etc/
rm -rf porttran/
clear
before_show_menu
}
check_install() {
if [ ! -d "$installfolder" ]; then
echo -e " ${red}<<转发没有安装>>"
else
echo -e " ${green}<<转发已经安装>>"
fi
}
before_show_menu() {
echo && echo -n -e "${yellow}操作完成按回车返回主菜单: ${plain}" && read temp
show_menu
}
update_shell() {
wget http://download.transitpool.org/porttraninstall/porttraninstall.sh -O -> /usr/bin/porttran-ui && chmod +x /usr/bin/porttran-ui && porttran-ui
echo
exit 0
}
update_app() {
kill_porttran
kill_ppexec
wget http://download.transitpool.org/porttraninstall/$version.tar.gz
tar -zxvf $version.tar.gz
cd porttran-$version/porttranpay
tar -zxvf porttranlatest.tar.gz
cd ../..
mv porttran-$version/porttranpay/porttran/portdir.sh porttran-$version/porttranpay/porttran/porttran
mkdir porttran && chmod 777 porttran
mv porttran-$version/porttranpay/porttran/* porttran
cd porttran/ && chmod +x porttran && chmod +x ppexec
cd ../
rm -rf porttran-$version
rm $version.tar.gz
rm porttranfree.sh
rm /etc/porttran/porttran
rm /etc/porttran/ppexec
rm -rf /etc/porttran/ui
cp porttran/ppexec /etc/porttran/
cp porttran/porttran /etc/porttran/
cd porttran/
cp -r ui /etc/porttran
cd ../
rm -rf porttran/
before_show_menu
}
uninstall_app() {
echo && echo -n -e "${yellow}确定卸载吗,按回车确定,CTRL+C退出: ${plain}" && read temp
kill_porttran
kill_ppexec
rm -rf /etc/porttran
before_show_menu
}
uninstall_shell() {
echo && echo -n -e "${yellow}确定卸载吗,按回车确定,CTRL+C退出: ${plain}" && read temp
rm /usr/bin/porttran-ui
before_show_menu
}
start() {
cd /etc/porttran
setsid ./porttran &
sleep 2
before_show_menu
}
stop() {
echo && echo -n -e "${yellow}确定停止吗,按回车确定,CTRL+C退出: ${plain}" && read temp
kill_porttran
kill_ppexec
before_show_menu
}
autorun() {
cd /etc
rm rc.local
touch rc.local
chmod 777 rc.local
echo "#!/bin/sh -e" >> rc.local
echo "#" >> rc.local
echo "# rc.local" >> rc.local
echo "#" >> rc.local
echo "# This script is executed at the end of each multiuser runlevel." >> rc.local
echo "# Make sure that the script will "#exit 0" on success or any other" >> rc.local
echo "# value on error." >> rc.local
echo "#" >> rc.local
echo "# In order to enable or disable this script just change the execution" >> rc.local
echo "# bits." >> rc.local
echo "#" >> rc.local
echo "# By default this script does nothing." >> rc.local
echo "#exit 0" >> rc.local
echo "cd /etc/porttran && setsid ./porttran &" >> rc.local
echo "exit 0" >> rc.local
cd /root
echo -e "${green}开机启动设置成功"
before_show_menu
}
show_menu() {
clear
check_install
echo -e "
${green}porttran脚本管理界面安装完成${red}版本${shell_version},转发软件版本${version}
${green}更新流程 4,7,2,6
${green}若启动错误请 7,6 重启
${green}任意目录下输入porttran-ui 启动管理界面
${red}转发软件浏览器默认端口62438,默认用户名密码admin,admin${plain}
————————————————
${green}0.${plain} 退出
————————————————
${green}1.${plain} 安装转发
${green}2.${plain} 更新转发
${green}3.${plain} 卸载转发
————————————————
${green}4.${plain} 更新脚本
${green}5.${plain} 卸载脚本
————————————————
${green}6.${plain} 启动转发
${green}7.${plain} 停止转发
${green}8.${plain} 开机启动
————————————————
"
echo && read -p "请输入选择 [0-8]: " num
case "${num}" in
0) exit 0
;;
1) install
;;
2) update_app
;;
3) uninstall_app
;;
4) update_shell
;;
5) uninstall_shell
;;
6) start
;;
7) stop
;;
8) autorun
;;
*) echo -e "${red}请输入正确的数字 [0-8]${plain}"
;;
esac
}
show_menu