#!/bin/sh

### BEGIN INIT INFO
# Provides:        pve-firewall
# Required-Start:  $remote_fs $network pvefw-logger pve-cluster
# Required-Stop:   $remote_fs $network pvefw-logger pve-cluster
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Proxmox VE firewall
### END INIT INFO

. /lib/lsb/init-functions

PATH=/sbin:/bin:/usr/bin:/usr/sbin
NAME=pve-firewall
DAEMON=/usr/sbin/$NAME
DESC="Proxmox VE firewall"
PIDFILE=/var/run/$NAME.pid

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
[ -e /proxmox_install_mode ] && exit 0
 
START_FIREWALL=yes

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

[ "$START_FIREWALL" = "yes" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

# avoid warnings about uninstalled locales
export LC_ALL="C"

case "$1" in
    start)
	log_daemon_msg "Starting $DESC" "$NAME"
	$DAEMON start
 	log_end_msg $?
  	;;
    stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	$DAEMON stop
	log_end_msg $?
  	;;
    status)
	$DAEMON status
	;;
    reload|restart|force-reload)
	log_daemon_msg "Restarting $DESC" "$NAME"
	$DAEMON restart
 	log_end_msg $?
  	;;
    *)
	N=/etc/init.d/$NAME
  	echo "Usage: $N {start|stop|status|restart|force-reload}"
  	exit 1
	;;
esac

exit 0
