I really like Ubuntu’s system V initialisation scripts and features. This is now based on the LSB standard. The Debian Wiki documents how to make an LSB init script here…. This has been replaced by systemd.
The script runs in different modes, LSB requires start, stop, restart, force-reload, and status modes.
Dependency is managed using a comment block, i.e. you can determine which services are required to be running before the service managed by the script. Here’s a zabbix example,
### BEGIN INIT INFO # Provides: zbxagentd # Required-Start: $network $local_fs # Required-Stop: $network $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts and stops zabbix_agentd # Description: starts and stops zabbix_agenta, suports all LSB script methods ### END INIT INFO
This depends on networks and disks.
With Ubuntu, there are a bunch of functions, loaded by
. /lib/lsb/init-functions
this declares helper function and a bunch of log writer scripts
In the Zabbix scripts, I used the program start-stop-daemon and the log_daemon_msg and log_end_msg to write the messages.
case "$1" in start) # I am unsure as to which configuration creates the .pid file log_daemon_msg "Starting $DESC: $NAME" start-stop-daemon --oknodo --start --pidfile $PID \ --exec $DAEMON case $? in 0) log_end_msg 0 ;; *) log_end_msg 1 ;; esac ;;
There are a couple more log write functions in the functions script.
The GeekStuff writes about it here…, and I posted the whole script to the zabbix forums before I implemented the LSB standard, this is also documented in my AWS post on this wiki.
I have uploaded the zabbix agent.