CASA/c_micasad/startup/micasad

94 lines
2.2 KiB
Plaintext
Raw Normal View History

2005-10-28 01:21:53 +02:00
#! /bin/sh
2006-01-25 19:41:48 +01:00
#
2005-10-28 01:21:53 +02:00
### BEGIN INIT INFO
2006-01-25 19:41:48 +01:00
# Provides: micasad
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 1 2 3 5
# Default-Stop:
# Short-Description: miCASA daemon
# Description: miCASA daemon
2005-10-28 01:21:53 +02:00
### END INIT INFO
MICASAD_BIN=/usr/bin/micasad.sh
2005-10-28 01:21:53 +02:00
test -x $MICASAD_BIN || exit 5
. /etc/rc.status
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# First reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting miCASA daemon"
for pam_file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm"
2005-10-28 01:21:53 +02:00
do
if [ -f $pam_file ]
2005-10-28 01:21:53 +02:00
then
MICASA_D=`grep -i micasad $pam_file`
if [ -z "$MICASA_D"]
then
awk '
/auth/ { authSeen++; }
/account/ {
if (!acctSeen && authSeen)
{
print "auth\trequired\tpam_micasa.so";}
acctSeen++;
}
/session/ { sesSeen++; }
// {print $0; }
END { if (sesSeen)
print "session\trequired\tpam_micasa.so"; }
' $pam_file > $pam_file.sav
mv $pam_file.sav $pam_file
fi
2005-10-28 01:21:53 +02:00
fi
done
startproc -f $MICASAD_BIN
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting miCASA daemon down"
#killproc -TERM $MICASAD_BIN
pid=`cat /var/run/micasad.pid`
kill -s TERM $pid
for pam_file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm"
2005-10-28 01:21:53 +02:00
do
if [ -f $pam_file ]
2005-10-28 01:21:53 +02:00
then
sed -i '/pam_micasa/d' $pam_file
2005-10-28 01:21:53 +02:00
fi
done
# Remember status and be verbose
rc_status -v
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
echo -n "Restarting miCASA daemon"
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
rc_exit