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.

Related Posts

  • Ubuntu 13.10 I am installing this on the Mac under Virtual Box. This snip is about Ubuntu. The […]
  • Snipsnap & Ubuntu Install Snipsnap I decided to test an install of Snipsnap on my favourite Linux. I am […]
  • Amazon Web Services I created this article in 2011, it was copied across to the wordpress wiki in the summer […]
  • LAMP & Ubuntu This should be easier, but I think made harder because I corrupted my Firefox […]
  • notify-send While installing docker, I decided I needed to write some notifications to ensure the […]

Leave a Reply

Your email address will not be published. Required fields are marked *

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