#!/bin/sh
##############################################################################
#
#  Copyright (c) 2008, Doremi Labs, Inc.
#    All rights reserved.
#
#  Redistribution in source or binary forms, with or without
#  modification, are NOT permitted.
#
#    Doremi Labs, Inc.
#    306 East Alameda Avenue
#    Burbank, CA 91502
#    Tel : (818) 562 1101
#    Fax : (818) 562 1109
#
#
##############################################################################

WALL=wall
SHUTDOWN=/sbin/shutdown
POPUP=/doremi/X11R6/bin/drmpopup.out
LANGCF=/doremi/etc/language

if test -x ${POPUP}; then
  TITLE="Alert! Imminent system halt"
  MESSAGE="<b>Going for shutdown in a minute!</b>"

  # translations
  if grep -qs fr-FR ${LANGCF}; then
    TITLE="Alerte! Arret du systeme imminent"
    MESSAGE="<b>Le systme va tre arrt dans moins d'une minute.</b>"
  fi

  ${POPUP} "${TITLE}" "<b>`date +'%a %b %-d, %Y ; %H:%M'`</b><br><br>${MESSAGE}" --warning
fi

echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
${SHUTDOWN} -h +1 "apcupsd UPS ${2} initiated shutdown"
exit 99
