System V init scripts

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….
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,

# 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

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
	# 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 ;;

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.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.