post_install () {
  # Check user/group munin exists
  getent group munin >/dev/null || groupadd --system munin
  getent passwd munin >/dev/null || \
	  useradd --system -c "Munin system monitor" -g munin -s /bin/false -d /var/lib/munin munin
  # Display cron command
  echo "See the example cron entry (for the munin user) for further setup:
    /etc/munin/munin-cron-entry"
  post_upgrade
}

post_upgrade() {
  # Ensure directories exist
  mkdir -p /var/{lib,log}/munin /run/munin
  # Fix permissions on necessary directories
  chown munin.munin /var/{lib,log}/munin /run/munin
  chown munin.munin /var/lib/munin/spool
  fc-cache /usr/lib/munin
}

post_remove() {
  fc-cache /usr/lib/munin
}
