﻿#!/bin/sh  

#add for chkconfig  
#chkconfig: 2345 70 30  
#description: the ss of the shell   #关于脚本的简短描述  
#processname: ss                    #第一个进程名，后边设置自启动的时候会用到  

#下面要启动服务的命令  

start()
{
ulimit -SHn 65535
cd /root/shadowsocks/
iptables -A INPUT -p tcp --dport 600:2000 -m connlimit --connlimit-above 3 -j DROP
iptables -A INPUT -p tcp --dport 600:2000 -m connlimit --connlimit-above 3 -j REJECT --reject-with tcp-reset
iptables -A OUTPUT -p 25 -j DROP
iptables -A INPUT -p tcp --dport 600:2000 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 600:2000 -j ACCEPT
service iptables save
service iptables restart
python server.py
}
stop()
{
iptables -F
service iptables save
service iptables restart
killall python
}
restart() {
        stop
        start
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
	 restart)
                restart
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart}"
                RETVAL=2
esac
