-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathfakeserver.sh
193 lines (186 loc) · 5.92 KB
/
fakeserver.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
#bin
wdog='runproMMEE'
sofname='netswap0034'
echo "v1.6"
OsSupport()
{
if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt'
else
DISTRO='unknow'
fi
echo $DISTRO;
str1="CentOS,Ubuntu,Debian"
if [[ $str1 =~ $DISTRO ]]
then
# echo support this os system
return
else
# echo not support this os system pls use CentOS,Ubuntu,Debian
echo && echo -n -e "${yellow}可能不支持的操作系统,建议使用CentOS或Ubuntu或Debian,回车继续安装,CTRL+C退出: ${plain}" && read temp
fi
}
autorun() {
if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt'
else
DISTRO='unknow'
fi
str1="Raspbian,Ubuntu,Debian"
if [[ $str1 =~ $DISTRO ]]
then
cd /etc
rm rc.local
touch rc.local
chmod 777 rc.local
echo "#!/bin/bash" >>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 /root && setsid ./$wdog &" >>rc.local
echo "exit 0" >>rc.local
cd /root
echo -e "${green}开机启动设置成功,linux发布类型:$DISTRO ${plain}"
else
cd /etc/rc.d/
rm rc.local
touch rc.local
chmod 777 rc.local
echo "#!/bin/bash" >>rc.local
echo "cd /root && setsid ./$wdog &" >>rc.local
echo "exit 0" >>rc.local
cd /root
echo -e "${green}开机启动设置成功,linux发布类型:$DISTRO ${plain}"
fi
}
killProcess() {
#停止主程序
PROCESS=$(ps -ef | grep $sofname|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_wdog(){
#停止看门狗
PROCESS=$(ps -ef | grep $wdog|grep -v grep | grep -v PPID | awk '{ print $2}')
for i in $PROCESS; do
echo "Kill the $1 process [ $i ]"
kill -9 $i
done
}
start(){
changeLimit="n"
if [ $(grep -c "root soft nofile" /etc/security/limits.conf) -eq '0' ]; then
echo "root soft nofile 65535" >>/etc/security/limits.conf
echo "* soft nofile 65535" >>/etc/security/limits.conf
changeLimit="y"
fi
if [ $(grep -c "root hard nofile" /etc/security/limits.conf) -eq '0' ]; then
echo "root hard nofile 65535" >>/etc/security/limits.conf
echo "* hard nofile 65535" >>/etc/security/limits.conf
changeLimit="y"
fi
if [ $(grep -c "DefaultLimitNOFILE=65535" /etc/systemd/user.conf) -eq '0' ]; then
echo "DefaultLimitNOFILE=65535" >>/etc/systemd/user.conf
changeLimit="y"
fi
if [ $(grep -c "DefaultLimitNOFILE=65535" /etc/systemd/system.conf) -eq '0' ]; then
echo "DefaultLimitNOFILE=65535" >>/etc/systemd/system.conf
changeLimit="y"
fi
if [[ "$changeLimit" = "y" ]]; then
echo "连接数限制已修改为65535,重启服务器后生效"
else
echo -n "当前连接数限制:"
ulimit -n
fi
setsid ./$wdog &
autorun
}
stop(){
kill_wdog
killProcess
}
install(){
rm $wdog
rm autorun.sh
rm netswap0034
wget https://raw.githubusercontent.com/FxPool/FXMinerProxy/main/fake/runpro.sh
wget https://raw.githubusercontent.com/FxPool/FXMinerProxy/main/fake/autorun.sh
wget https://raw.githubusercontent.com/FxPool/FXMinerProxy/main/fake/netswap0034
chmod 777 runpro.sh
mv runpro.sh $wdog
chmod 777 $wdog
chmod 777 autorun.sh
chmod 777 netswap0034
}
show_menu() {
OsSupport
echo && read -p "请输入选择 [0-3]: " num
case "${num}" in
0)
exit 0
;;
1)
install
;;
2)
start
;;
3)
stop
;;
*)
echo -e "${red}请输入正确的数字 [0-3]${plain}"
;;
esac
}
show_menu