ubuntu-ss的一些配置
ubuntu 16.04的系统配置文件开机自启一直没弄清楚,这次大哥改了一下ss服务器的端口我又找了一启动文件的配置,因此进行一个记录。
开机自启
/etc/init.d/
是一个开机自启的系统文件夹。 将sslocal放在内部,里面的shell是抄的以前抄的网上的…来源忘了,不过谢谢老哥。
#!/bin/bash
### BEGIN INIT INFO
# Provides: Shadowsocks-local
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: A secure socks5 proxy, designed to protect your Internet traffic.
### END INIT INFO
# Author: lynnyq <lynnyq@gmail.com>
name=sslocal
BIN=/usr/local/bin/sslocal
conf=/etc/shadowsocks/config.json
start(){
$BIN -c $conf -d start
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name start success"
else
echo "$name start failed"
fi
}
stop(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ ! -z $pid ]]; then
$BIN -c $conf -d stop
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name stop success"
else
echo "$name stop failed"
fi
else
echo "$name is not running"
RETVAL=1
fi
}
status(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ -z $pid ]]; then
echo "$name is not running"
RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'status')
status
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL
另外只需要更改conf=/etc/shadowsocks/config.json
里面的配置信息既可