Added startup file for init.d

This commit is contained in:
Roger Ye 2021-11-13 10:38:57 +08:00
parent cbdd73b94f
commit c647439965

102
conf/init.d/frps Executable file
View File

@ -0,0 +1,102 @@
#!/bin/sh
#
# frps Starts/stop the "frps" daemon
#
# chkconfig: 2345 55 25
# description: frp is a fast reverse proxy
# processname: frps
# config: /etc/frp/frps.ini
### 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: Starts/stop the "frps" daemon
# Description: frp is a fast reverse proxy
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
FRPS_BIN=/usr/bin/frps
prog="frps"
config=/etc/frp/frps.ini
lockfile=/var/lock/subsys/$prog
PID_FILE=/var/run/frps.pid
start() {
[ -x $FRPS_BIN ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon $FRPS_BIN -c $config &
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
}
stop() {
echo -n $"Stopping $prog: "
killproc $FRPS_BIN
RETVAL=3
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?