File policyd-weight of Package policyd-weight
#!/bin/sh
#
# policyd-weight startup script
#
# chkconfig: 2345 80 30
# description: policyd-weight
#
### BEGIN INIT INFO
# Provides: policyd-weight
# Required-Start: postfix $remote_fs
# Required-Stop: postfix $remote_fs
# Default-Start: 3 5
# Default-Stop:
# Short-Description: Weighted policy daemon for postfix
# Description: Controls policyd-weight daemon
### END INIT INFO
# 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_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
cd /
if [ -f /etc/rc.status ]; then
. /etc/rc.status
fi
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
if [ -f /etc/rc.status ]; then
# First reset status of this service
rc_reset
fi
RETVAL=0
prog="policyd-weight"
PIDFILE=/var/run/policyd-weight.pid
startf() {
# Start daemons.
echo -n "Starting policyd-weight: "
/usr/sbin/policyd-weight start 2>/dev/null 1>&2 && success || failure $"$prog start"
RETVAL=$?
echo
return $RETVAL
}
stopf() {
# Stop daemons.
echo -n $"Shutting down policyd-weight (master): "
/usr/sbin/policyd-weight stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
RETVAL=$?
echo
return $RETVAL
}
stopcachef() {
# Stop cache daemon.
echo -n $"Shutting down policyd-weight (cache): "
/usr/sbin/policyd-weight -k 2>/dev/null 1>&2 && success || failure $"$prog stopall"
RETVAL=$?
echo
return $RETVAL
}
restartf() {
# Restart daemons.
echo -n "Restarting policyd-weight: "
/usr/sbin/policyd-weight restart 2>/dev/null 1>&2 && success || failure $"$prog restart"
RETVAL=$?
echo
return $RETVAL
}
reloadf() {
# Reload configuration file
echo -n "Reloading policyd-weight configuration: "
/usr/sbin/policyd-weight reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
'start')
if [ -f /etc/init.d/functions ]; then
startf
fi
if [ -f /etc/rc.status ]; then
echo -n "Starting policyd-weight: "
if ! checkproc -p $PIDFILE /usr/sbin/policyd-weight; then
/usr/sbin/policyd-weight start > /dev/null 2>&1
else
rc_reset
fi
rc_status -v
fi
;;
'stop')
if [ -f /etc/init.d/functions ]; then
stopf
fi
if [ -f /etc/rc.status ]; then
echo -n $"Shutting down policyd-weight (master): "
/usr/sbin/policyd-weight -k stop > /dev/null 2>&1
rc_status -v
fi
;;
'stopall')
if [ -f /etc/init.d/functions ]; then
PID1=$(pidof "${prog} (master)")
PID2=$(pidof "${prog} (cache)")
if [ "$PID1" != "" ]
then
stopf
fi
if [ "$PID2" != "" ]
then
stopcachef
fi
fi
if [ -f /etc/rc.status ]; then
echo -n $"Shutting down policyd-weight (master): "
/usr/sbin/policyd-weight stop > /dev/null 2>&1
rc_status -v
echo -n $"Shutting down policyd-weight (cache): "
/usr/sbin/policyd-weight -k > /dev/null 2>&1
rc_status -v
fi
;;
'restart')
if [ -f /etc/init.d/functions ]; then
restartf
fi
if [ -f /etc/rc.status ]; then
echo -n "Restarting policyd-weight: "
/usr/sbin/policyd-weight restart > /dev/null 2>&1
rc_status
fi
;;
'reload')
if [ -f /etc/init.d/functions ]; then
reloadf
fi
if [ -f /etc/rc.status ]; then
echo -n "Reloading policyd-weight configuration: "
/usr/sbin/policyd-weight reload > /dev/null 2>&1
rc_status -v
fi
;;
'status')
if [ -f /etc/init.d/functions ]; then
PID1=$(pidof "${prog} (master)")
PID2=$(pidof "${prog} (cache)")
if [ "$PID1" != "" ]
then
echo "$prog (master) is running: ($PID1)"
else
echo "$prog (master) is NOT running"
fi
if [ "$PID2" != "" ]
then
echo "$prog (cache) is running: ($PID2)"
else
echo "$prog (cache) is NOT running"
fi
fi
if [ -f /etc/rc.status ]; then
echo -n "Checking: "
if [ -f /var/run/policyd-weight.pid ]; then
rc_failed 0
rc_status -v
exit 0
else
rc_failed 3
rc_status -v
exit 3
fi
fi
;;
*)
echo "Usage: $0 {start|stop|stopall|restart|reload|status}"
;;
esac
exit 0