ShadowsocksR 注册成服务开机启动

ShadowsocksR安装好了,但是启动不大方便,于是我想了一个通过服务的形式方便快速的启动,停用,重启,查看运行状态等。 捕获.jpg 以下是实现方法:

  1. 在 /etc/init.d目录下新建一个服务项目(ss)

    vim /etc/init.d/ss

    #!/bin/sh

    BEGIN INIT INFO

    Provides: ss

    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.

    This package contain local and server part of shadowsocks, a fast,

    powerful tunnel proxy to bypass firewalls.

    END INIT INFO

    Load the VERBOSE setting and other rcS variables

    . /lib/init/vars.sh

    Define LSB log_* functions.

    Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

    . /lib/lsb/init-functions

    Author: Kay lee [email protected]

    ss_path=/srv/www/html/shadowsocks

    start(){ echo “start Shadowsocks service..”; sh ${ss_path}/logrun.sh; }

    stop(){ echo “stop Shadowsocks service..”; sh ${ss_path}/stop.sh;

    }

    restart(){ echo “stop Shadowsocks service..”; stop && start;

    }

    statu(){ sh ${ss_path}/tail.sh;

    }

    case “$1” in start) start ;; stop) stop ;; restart) restart ;; statu) statu ;; *) echo “Usage: $0 (start|stop|restart|statu)” exit 1 ;; esac

  2. 给该文件赋权限755

    chmod 755 /etc/init.d/ss 注册ss服务自启动

    update-rc.d ss defaults

chkconfig --add sschkconfig ngrok on

这样就可以通过

/etc/init.d/ss (start|stop|restart|statu) 

或者

service ss (start|stop|restart|statu) 

实现啦!

熬夜写下的,累成狗了!

睡觉啊~~~~~~~~~

Licensed under CC BY-NC-SA 4.0
最后更新于 Oct 14, 2016 15:26 UTC
点击刷新🚌