forked from godzlalala/SWEB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sweb
executable file
·54 lines (45 loc) · 1.32 KB
/
sweb
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
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#Check Root
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; }
echo '1.开启SWEB'
echo '2.关闭SWEB'
echo '3.修改网页密码'
while :; do echo
read -p "请选择你要的功能:" choice
if [[ ! $choice =~ ^[1-2]$ ]]; then
echo "输入错误! 请输入正确的数字!"
else
break
fi
done
cgipid=$(ps -ef | grep -v grep | grep -i "CGIHTTPServer" | awk '{print $2}')
if [[ ${choice} == 1 ]];then
if [[ cgipid == "" ]];then
cd /usr/local/SWEB
screen -dmS SWEB python CGIHTTPServer.py
fi
service caddy start
/etc/init.d/shadowsocks start
iptables -I INPUT -p tcp --dport 8000 -j DROP
iptables -I INPUT -s 127.0.0.1 -p tcp --dport 8000 -j ACCEPT
fi
if [[ ${choice} == 2 ]];then
if [[ cgipid != "" ]];then
kill -s 9 ${cgipid}
screen -wipe SWEB
fi
service caddy stop
/etc/init.d/shadowsocks stop
fi
if [[ ${choice} == 3 ]];then
read -p "请输入新的面板用户名:" webuser
read -p "请输入新的面板密码:" webpassword
rm -rf /usr/local/caddy/Caddyfile
echo ":80 {
basicauth / $webuser $webpasswd
proxy / http://127.0.0.1:8000
}" > /usr/local/caddy/Caddyfile
service caddy restart
echo "修改成功!"
fi