#!/bin/sh

# This script is called via inittab on shutdown.
# Its purpose is to stop the applications so that the disk parititions
# may be remounted read-only.

APPS="CompressorApp GatewayApp VoicemailApp AdminModule"

echo "Sending SIGTERM to applications"

for app in $APPS; do
	killall -TERM $app
done

sleep 2

echo "Sending SIGKILL to applications"

for app in $APPS; do
	killall -KILL $app
done

# Web server has dedicated control script ...
/usr/apache2/bin/apachectl stop

# Save system time to RTC (unless NTP has done it)
status=`adjtimex -p | awk '$1~/status/{print $2}'`
[ $status -ne 1 ] && hwclock -uw

