forked from syapik96/aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssr.sh
157 lines (151 loc) · 5.02 KB
/
ssr.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
#!/bin/bash
### Telegram: https : //t.me/ALKNET
### Back to old type configuration ,,, while do update facing issue ..
### Method use from : https://github.com/alkhanet26
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
sh_ver="1.0.26"
filepath=$(cd "$(dirname "$0")"; pwd)
file=$(echo -e "${filepath}"|awk -F "$0" '{print $1}')
ssr_folder="/usr/local/shadowsocksr"
config_file="${ssr_folder}/config.json"
config_user_file="${ssr_folder}/user-config.json"
config_user_api_file="${ssr_folder}/userapiconfig.py"
config_user_mudb_file="${ssr_folder}/mudb.json"
ssr_log_file="${ssr_folder}/ssserver.log"
Libsodiumr_file="/usr/local/lib/libsodium.so"
Libsodiumr_ver_backup="1.0.17"
jq_file="${ssr_folder}/jq"
source /etc/os-release
OS=$ID
ver=$VERSION_ID
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[information]${Font_color_suffix}"
Error="${Red_font_prefix}[error]${Font_color_suffix}"
Tip="${Green_font_prefix}[note]${Font_color_suffix}"
Separator_1="——————————————————————————————"
check_pid(){
PID=`ps -ef |grep -v grep | grep server.py |awk '{print $2}'`
}
Add_iptables(){
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 1443:1543 -j ACCEPT
iptables -I INPUT -m state --state NEW -m udp -p udp --dport 1443:1543 -j ACCEPT
}
Save_iptables(){
if [[ ${OS} == "centos" ]]; then
service iptables save
service ip6tables save
else
iptables-save > /etc/iptables.up.rules
fi
}
Set_iptables(){
if [[ ${OS} == "centos" ]]; then
service iptables save
service ip6tables save
chkconfig --level 2345 iptables on
chkconfig --level 2345 ip6tables on
else
iptables-save > /etc/iptables.up.rules
echo -e '#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules\n/sbin/ip6tables-restore < /etc/ip6tables.up.rules' > /etc/network/if-pre-up.d/iptables
chmod +x /etc/network/if-pre-up.d/iptables
fi
}
Set_user_api_server_pub_addr(){
ip=$(wget -qO- icanhazip.com);
ssr_server_pub_addr="${ip}"
}
Modify_user_api_server_pub_addr(){
sed -i "s/SERVER_PUB_ADDR = '${server_pub_addr}'/SERVER_PUB_ADDR = '${ssr_server_pub_addr}'/" ${config_user_api_file}
}
Check_python(){
if [[ ${OS} == "centos" ]]; then
if [[ $ver == '7' ]]; then
yum -y install python
elif [[ $ver == '8' ]]; then
yum install -y python2
alternatives --set python /usr/bin/python2
fi
else
apt-get install -y python
fi
}
Centos_yum(){
yum update
cat /etc/redhat-release |grep 7\..*|grep -i centos>/dev/null
if [[ $? = 0 ]]; then
yum install -y vim unzip crond net-tools git
else
yum install -y vim unzip crond git
fi
}
Debian_apt(){
apt-get update
apt-get install -y vim unzip cron git net-tools
}
Download_SSR(){
cd "/usr/local"
git clone -b akkariiin/master https://github.com/shadowsocksrr/shadowsocksr.git
cd "shadowsocksr"
cp "${ssr_folder}/config.json" "${config_user_file}"
cp "${ssr_folder}/mysql.json" "${ssr_folder}/usermysql.json"
cp "${ssr_folder}/apiconfig.py" "${config_user_api_file}"
sed -i "s/API_INTERFACE = 'sspanelv2'/API_INTERFACE = 'mudbjson'/" ${config_user_api_file}
server_pub_addr="127.0.0.1"
Modify_user_api_server_pub_addr
sed -i 's/ \/\/ only works under multi-user mode//g' "${config_user_file}"
}
Service_SSR(){
if [[ ${OS} = "centos" ]]; then
wget --no-check-certificate "https://raw.githubusercontent.com/hybtoy/ssrrmu/master/ssrmu_centos" -O /etc/init.d/ssrmu
chmod +x /etc/init.d/ssrmu
chkconfig --add ssrmu
chkconfig ssrmu on
else
wget --no-check-certificate "https://raw.githubusercontent.com/hybtoy/ssrrmu/master/ssrmu_debian" -O /etc/init.d/ssrmu
chmod +x /etc/init.d/ssrmu
update-rc.d -f ssrmu defaults
fi
}
JQ_install(){
cd "${ssr_folder}"
wget --no-check-certificate "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -O ${jq_file}
chmod +x ${jq_file}
}
Installation_dependency(){
if [[ ${OS} == "centos" ]]; then
Centos_yum
service crond restart
else
Debian_apt
/etc/init.d/cron restart
fi
}
Start_SSR(){
check_pid
wget -O /etc/init.d/ssrmu "https://raw.githubusercontent.com/akiraafudo/vpn-script/master/ssrmu"
/etc/init.d/ssrmu start
}
Install_SSR(){
Set_user_api_server_pub_addr
Check_python
Installation_dependency
Download_SSR
Service_SSR
JQ_install
Set_iptables
Add_iptables
Save_iptables
Start_SSR
}
GitUser="alkhanet26"
# Install_SSR
cd /usr/local/sbin
wget -O /usr/bin/ssr "https://raw.githubusercontent.com/${GitUser}/aws/main/menu-update/ssr.sh" && chmod +x /usr/bin/ssr
wget -O addssr "https://raw.githubusercontent.com/${GitUser}/aws/main/tambah/addssr.sh" && chmod +x addssr
wget -O delssr "https://raw.githubusercontent.com/${GitUser}/aws/main/hapus/delssr.sh" && chmod +x delssr
wget -O xp-ssr "https://raw.githubusercontent.com/${GitUser}/aws/main/xp-ssr.sh" && chmod +x xp-ssr
wget -O renewssr "https://raw.githubusercontent.com/${GitUser}/aws/main/renewssr.sh" && chmod +x renewssr
touch /usr/local/shadowsocksr/akun.conf
rm -f /root/ssr.sh
echo "0 0 * * * root xp-ssr" >> /etc/crontab