hahawo

by liuyumei
19 deployments · 14 still active · last rev. 19 days ago

ssfangzhi

Compatible with: CentOS 7
						#! /bin/bash
sudo yum update -y
sudo yum install epel-release -y
sudo yum install python-setuptools -y
sudo easy_install pip
sudo pip install shadowsocks
sudo iptables -F
sudo timedatectl set-timezone Asia/Shanghai
sudo 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

sudo 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

sudo systemctl enable shadowsocks 
sudo systemctl start shadowsocks

sudo 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

sudo crontab temp.txt
sudo rm -f temp.txt
sudo 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

sudo 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