Sys-V init script

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2022-04-21 18:28:53 +00:00
parent 337b353624
commit 6d29c032a7
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
3 changed files with 64 additions and 30 deletions

View File

@ -1,21 +0,0 @@
#!/bin/sh
# PROVIDE: catsitd
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name="catsitd"
rcvar="${name}_enable"
extra_commands="reload"
load_rc_config $name
: ${catsitd_enable:="NO"}
command="%%PREFIX%%/sbin/${name}"
pidfile="/var/run/${name}.pid"
command_args="-p ${pidfile}"
run_rc_command "$1"

View File

@ -1,9 +0,0 @@
#!/bin/ksh
daemon="%%PREFIX%%/sbin/catsitd"
. /etc/rc.d/rc.subr
pexp="catsitd: .*"
rc_cmd $1

64
rc.catsit Normal file
View File

@ -0,0 +1,64 @@
#!/bin/sh
# Trying to run catsit on a Linux kernel
# Georg Pfuetzenrueter <mail@georg-pfuetzenreuter.net>
NAME="catsit"
SVCUSER="gsvc01"
SVCHOME="/var/lib/cradle"
PREFIX="/usr/local"
CONF="$PREFIX/etc/$NAME.conf"
BIN="$PREFIX/sbin/${NAME}d"
rundir="/run/$NAME"
pipe="$rundir/${NAME}d"
pidfile="$rundir/${NAME}d.pid"
command_args="-C ${SVCHOME} -c ${pipe} -p ${pidfile} -t 5 -u ${SVCUSER}"
# Exit if the binary is not installed
if [ ! -x "$BIN" ];
then
exit 0
fi
do_start() {
mkdir $rundir
chown $SVCUSER:$SVCUSER $rundir
$BIN $command_args
}
do_reload() {
pkill -HUP -F $pidfile
}
do_stop() {
pkill -F $pidfile
rmdir $rundir
}
do_status() {
echo "Not properly implemented."
pkill -PWR -F $pidfile
}
case "$1" in
start)
do_start
;;
reload)
do_reload
;;
restart)
do_stop
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|status}" >&2
exit 3
;;
esac