Reload strlist and iplist resource-files only when needed.
[apps/pfixtools.git] / example / postlicyd.initd.sh
1 #!/bin/sh
2
3 die() {
4   echo "$1"
5   exit 1
6 }
7
8 POSTLICYD=/usr/sbin/postlicyd
9 PIDFILE=/var/run/postlicyd/pid
10 CONF=/etc/pfixtools/postlicyd.conf
11
12 [ -z $1 ] && die "usage $0 (start|stop|reload|check-conf)"
13
14 mkdir -p `dirname "$PIDFILE"` || die "Can't create $PIDFILE"
15
16 do_checkconf() {
17   $POSTLICYD -c "$CONF"
18   return "$?"
19 }
20
21 case "$1" in
22   start)
23     echo "Starting postlicyd..."
24     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $POSTLICYD --text > /dev/null || die "Already running"
25     do_checkconf || die "Invalid configuration"
26     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $POSTLICYD -- -p "$PIDFILE" "$CONF" || die "Failed"
27     echo "Started"
28     ;;
29
30   stop)
31     echo "Stopping postlicyd..."
32     start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name "postlicyd"
33     case "$?" in
34       0) echo "Stopped" ;;
35       1) die "Nothing to stop" ;;
36       2) die "Cannot stop process" ;;
37     esac
38     ;;
39
40   reload)
41     echo "Reloading postlicyd..."
42     do_checkconf || die "Invalid configuration"
43     start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name postlicyd
44     ;;
45
46   check-conf)
47     do_checkconf || die "Invalid configuration"
48     ;;
49
50   *)
51     die "usage $0 (start|stop|reload|check-conf)"
52     ;;
53 esac