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,

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

Related Posts

  • Ubuntu 13.10 I am installing this on the Mac under Virtual Box. This snip is about Ubuntu. The […]
  • File Transfer I need to revise file transfer over TCP/IP. This article consists of links on […]
  • Centos 6.x I downloaded this from http://centos.mirroring.pulsant.co.uk/6.4/isos/x86_64/ The […]
  • Snipsnap & Ubuntu Install Snipsnap I decided to test an install of Snipsnap on my favourite Linux. I am […]
  • RCS Revision Control System, one of the grand daddies of them all. I still use it because […]

Leave a Reply

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