注意替换DAEMON,CONFIG的路径哦。

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          rufei.ren
# Required-Start:    $network $remote_fs $local_fs
# Required-Stop:     $network $remote_fs $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: autostartup of frp client for RaspberryPi
### END INIT INFO


NAME=frpc
DAEMON=/usr/frp/$NAME
CONFIG=/usr/frp/frpc.ini
PIDFILE=/var/run/$NAME.pid

[ -x "$DAEMON" ] || exit 0

case "$1" in
  start)
      if [ -f $PIDFILE ]; then
        echo -n "$NAME already running"
        echo "."
    else
        echo "Starting $NAME..."
        start-stop-daemon -S -x $DAEMON -p $PIDFILE -m -b -o -q -- -c $CONFIG|| return 2
        echo "."
    fi
    ;;
  stop)
            echo "Stoping $NAME..."
        start-stop-daemon -K -p $PIDFILE -s TERM -o -q || return 2
        rm -rf $PIDFILE
        echo "."
    ;;
  restart)
    $0 stop && sleep 2 && $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac
exit 0

相关命令

sudo /etc/init.d/frp start    #开启
sudo /etc/init.d/frp stop     #关闭
sudo /etc/init.d/frp restart  #重启

cd /etc/init.d
sudo update-rc.d natapp defaults 90    #加入开机启动
sudo update-rc.d -f natapp remove  #取消开机启动
最后修改:2017 年 11 月 13 日
如果觉得我的文章对你有用,请随意赞赏