#!/bin/sh
# Starts up the warden service
######################################################################

PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
export PATH

# Source our functions
PROGDIR="${1}"

if [ -z "${PROGDIR}" ]
then
   echo "PROGDIR unset! Is The Warden installed properly?"
   exit 155
fi

# Source our variables
. ${PROGDIR}/conf/warden.conf

echo "Stopping the Warden"

cd ${JDIR}
for i in `ls -d *`
do
  ${PROGDIR}/scripts/backend/checkstatus.sh "${i}" 2>/dev/null
  if [ "$?" = "0" ]
  then
    echo "Stopping jail (${i})"
    ${PROGDIR}/scripts/backend/stopjail.sh "${i}" "FAST"
  fi
done

