#!/bin/bash
### BEGIN INIT INFO
# Provides:          invirt-remote-host
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: remctl configuration for an Invirt host
# Description:
### END INIT INFO 

PACKAGE=invirt-remote-host

. /lib/lsb/init-functions

gen_config()
{
    for i in /etc/remctl/acl/remote
    do mako-render $i.mako > $i
    done
}

case "$1" in
  start|reload|force-reload|restart)
    log_begin_msg "Reloading config for $PACKAGE"
    gen_config
    log_end_msg $?
    invoke-rc.d openbsd-inetd start # returns 1 if inetd is running
    [ $? -eq 1 ] && exit 0
    ;;
  stop)
    ;;
  *)
    log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}"
    ;;
esac
