hahawo

by liuyumei
3 deployments · 3 still active · last rev. 9 days ago

ssfangzhi

Compatible with: CentOS 7
						#! /bin/bash
sudo yum update -y
yum install epel-release -y
yum install python-setuptools -y
easy_install pip
pip install shadowsocks
iptables -F
timedatectl set-timezone Asia/Shanghai
cat <<EOF | sudo tee /etc/shadowsocks.json
{
  "server": "0.0.0.0",
  "port_password": {
        "8009": "726372",
        "5627": "657567",
        "3429": "452535",
        "5560": "023892",
        "7907": "343546"
    },
  "method": "aes-256-cfb"
}
EOF

cat <<EOF | sudo tee /etc/systemd/system/shadowsocks.service 
[Unit]
Description=Shadowsocks

[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json

[Install]
WantedBy=multi-user.target
EOF

systemctl enable shadowsocks 
systemctl start shadowsocks

cat <<EOF | sudo tee temp.txt
* * * * * /root/keepss.sh shadowsocks
@reboot service iptables stop;iptables -A INPUT -p tcp --sport 1024:10240 -m limit --limit 1000/s -j ACCEPT;iptables -A INPUT -p tcp --sport 1024:10240 -j DROP;service iptables save;service iptables start

EOF

crontab temp.txt
rm -f temp.txt
cat <<EOF|sudo tee keepss.sh
#! /bin/bash
for D in $@
do
C=$(/usr/bin/systemctl status ${D}|grep -c running)
if [ $C -eq 0 ]
then
/usr/bin/systemctl restart $D
fi
done
EOF

chmod 777 *.sh

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
yum install iptables-services -y
service iptables start;service iptables stop;iptables -A INPUT -p tcp --sport 1024:10240 -m limit --limit 1000/s -j ACCEPT;iptables -A INPUT -p tcp --sport 1024:10240 -j DROP;service iptables save;service iptables start