#!/bin/sh
#-------------------------------------------------------------------------------
# charon_menu_walloff
#-------------------------------------------------------------------------------
#
#set -x
VERSION=1.0a

. `dirname $0`/charon_common
. `dirname $0`/charon_common_menu

WALLOFFFILE="/root/.charonwalloff"
echo

display_header "Enable/disable wall alert messages"
echo

if test `id -u` -ne 0
then
  tput bold
  echo "Must be root !"
  tput sgr0
  Press_Enter
  echo
  exit 1
fi

if test ! -x /opt/charon/utils/charon_check.alertcmd
then
  cp -f charon_check.alertcmd.example charon_check.alertcmd
  echo "Mail script initialized."
  echo
fi

while test 1
do
  display_header "Enable/disable wall alert messages"
  echo

  printf "Wall alerts message are "
  if test -e ${WALLOFFFILE}
  then
    echo "[1m[31mdisabled[0m"
    WALLMODE=0
  else
    echo "[1m[32menabled[0m"
    WALLMODE=1
  fi
  echo
  printf "Enter 's' to switch, 'q' to quit : "
  read ANS
  echo
  case "${ANS}"
  in
    s)
      if test -e ${WALLOFFFILE}
      then
        rm -f ${WALLOFFFILE}
      else
        touch ${WALLOFFFILE}
      fi
      ;;
    q)
      break
      ;;      
  esac
done
echo

exit
