After reviewing the control.sh file that Cronicle uses, I've run into a little trouble creating a proper OpenRC script. The most that I have down is this:
#!/sbin/openrc-run
#
# OpenRC script for Cronicle Scheduler
#
# chkconfig: 345 90 10
# description: Cronicle Scheduler
### BEGIN INIT INFO
# Provides: cronicled
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/Stop Cronicle Scheduler
### END INIT INFO
NAME="Cronicle Daemon"
DESCRIPTION="A cron alternative built on Node.js, sporting a web GUI"
# COMMAND="/opt/cronicle/bin/control.sh"
PIDFILE=$HOMEDIR/logs/cronicled.pid
depend() {
need localmount net syslog-ng connmand
provide cronicled
}
Everything after this point is questionable. The COMMAND part can't remain as it is because it calls another script. But, when looking at Cronicle's control script (control.sh), this is what I encountered:
case $ARG in
start)
if [ $RUNNING -eq 1 ]; then
echo "$ARG: $NAME already running (pid $PID)"
continue
fi
echo "$0 $ARG: Starting up $NAME..."
if $BINARY ; then
echo "$0 $ARG: $NAME started"
else
echo "$0 $ARG: $NAME could not be started"
ERROR=3
fi
;;
stop)
if [ $RUNNING -eq 0 ]; then
echo "$ARG: $STATUS"
continue
fi
if kill $PID ; then
while [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; do
sleep 1;
done
echo "$0 $ARG: $NAME stopped"
else
echo "$0 $ARG: $NAME could not be stopped"
ERROR=4
fi
;;
restart)
$0 stop start
;;
status)
echo "$ARG: $STATUS"
;;
esac
It's using a bunch of case statements. That alone doesn't trouble me (though I am a newb at this, so maybe it should?). What causes me trouble is how the binary or command gets executed, and what I should set $COMMAND to:
start)
if [ $RUNNING -eq 1 ]; then
echo "$ARG: $NAME already running (pid $PID)"
continue
fi
echo "$0 $ARG: Starting up $NAME..."
if $BINARY ; then
echo "$0 $ARG: $NAME started"
else
echo "$0 $ARG: $NAME could not be started"
ERROR=3
fi
;;
...
...
...
stop)
...
if kill $PID ; then
while [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; do
sleep 1;
done
echo "$0 $ARG: $NAME stopped"
I'm not sure how the start command works at this time. Is it using the $BINARY variable to start the service? I don't think the script is calling itself and tacking an argument to the end, like $0 $ARG , but I could be wrong. The stop command calls kill $PID to kill it by PID. They appear to use two different methods to control the service's execution. Upon first glance, I'm tempted to use $BINARY for $COMMAND. That variable appears to call Node.js and tell it to run main.js. Is that a correct observation?
I'm not sure how to implement the start() and stop() functions for this.