Skip to content

Instantly share code, notes, and snippets.

@c2h2
Forked from KyonLi/frps
Created May 25, 2023 17:24
Show Gist options
  • Save c2h2/efa76ec4adf15bd115d362c260447874 to your computer and use it in GitHub Desktop.
Save c2h2/efa76ec4adf15bd115d362c260447874 to your computer and use it in GitHub Desktop.
frps init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: frps
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: frps service deamon
# Description: frps service daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/frps
DAEMON_OPTS="-c /etc/frp/frps.ini"
NAME=frps
USER=nobody
set -e
. /lib/lsb/init-functions
start() {
echo -n "Starting $NAME: "
start-stop-daemon --start \
--user $USER \
-m --pidfile /var/run/$NAME.pid \
-b --exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
}
stop() {
echo -n "Stopping $NAME: "
start-stop-daemon --stop \
--pidfile /var/run/$NAME.pid || true
echo "$NAME."
}
status() {
status_of_proc -p /var/run/$NAME.pid "$DAEMON" $NAME && exit 0 || exit $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
sleep 2
start
;;
*)
echo "Usage: $NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment