#! /bin/sh

### BEGIN INIT INFO
# Provides:          munin
# Required-Start:    $network $named $local_fs $remote_fs
# Required-Stop:     $network $named $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Create munin master directories on boot
# Description:       Create munin master directories on boot. Munin itself runs as CGI or via cron and does not run a separate daemon.
### END INIT INFO


# systemd creates the necessary directories (see /usr/lib/tmpfiles.d/munin-common.conf)
test -d /run/systemd/system && exit 0


. /lib/lsb/init-functions

case "$1" in
  start|restart|force-reload)
	# Create various directories
	# keep in sync with debian/munin-common.tmpfile (systemd-only)
	mkdir -p /run/munin && chown munin /run/munin && chmod 755 /run/munin
	mkdir -p /var/cache/munin/www && chown munin. /var/cache/munin/www && chmod 755 /var/cache/munin/www
	exit $?
	;;
  stop)
	# Nothing to do
	exit $?
	;;
  *)
	echo "Usage: /etc/init.d/munin" \
			"{start|stop}"
	exit 2
	;;
esac
