SHARE
TWEET

ng

a guest Jan 27th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          github.com/MCUmbrella
  4. # Required-Start:    $network $remote_fs $local_fs
  5. # Required-Stop:     $network $remote_fs $local_fs
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: ngrok
  9. ### END INIT INFO
  10. #本服务需要安装screen才能正常运行(apt install screen)
  11. NAME=ng
  12. DAEMON=【ngrok可执行文件路径】
  13. PIDFILE=/var/run/$NAME.pid
  14.  
  15. [ -x "$DAEMON" ] || exit 0
  16.  
  17. case "$1" in
  18.   start)
  19.       if [ -f $PIDFILE ]; then
  20.         echo "$NAME already running..."
  21.         echo -e "\033[1;35mStart Fail\033[0m"
  22.       else
  23.         echo "Starting $NAME..."
  24.         screen -dmS ng $DAEMON -- -config=【配置文件路径】 start 【映射名】|| return 2
  25.         echo -e "\033[1;32mStart Success\033[0m"
  26.     fi
  27.     ;;
  28.   stop)
  29.         echo "Stoping $NAME..."
  30.         kill $(pidof -x ngrok) || return 2
  31.         rm -rf $PIDFILE
  32.         echo -e "\033[1;32mStop Success\033[0m"
  33.     ;;
  34.   restart)
  35.     $0 stop && sleep 2 && $0 start
  36.     ;;
  37.   *)
  38.     echo "Usage: $0 {start|stop|restart}"
  39.     exit 1
  40.     ;;
  41. esac
  42. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top