aboutsummaryrefslogtreecommitdiff
path: root/network/policyd/rc.policyd
blob: 06f87a21e8d7b87027337ff74f78b66d0d3193d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
#
# /etc/rc.d/rc.policyd
#
# start/stop/restart Policy daemon for Postfix
# 
# The PIDFILE is setup in the config file. Default is /var/run/policyd.pid
# If you change the location in the config file then it **needs** to be 
# changed here too.

PIDFILE="/var/run/policyd.pid"
CONFIG="/etc/policyd.conf"

policyd_start() {
  if [ -x /etc/rc.d/rc.policyd ]; then
	if [ -f $PIDFILE ]; then
		echo "Policy daemon seems to be running with PID: $(cat $PIDFILE)"
	else
		if [ -r "$CONFIG" ]; then
			echo "Starting Policy daemon"
	    		/usr/bin/policyd -c $CONFIG
		else
			echo "$CONFIG is missing or unreadable.  Exiting..."
			exit 1
		fi
	fi
  fi
}

policyd_stop() {
	if [ -f $PIDFILE ]; then
		echo "Stopping Policy daemon"
		/bin/kill $(cat $PIDFILE)
  		rm -f $PIDFILE
	else
		echo "Policy daemon is not running..."
		exit 1
	fi
}

policyd_restart() {
  policyd_stop
  sleep 2
  policyd_start
}

case "$1" in
'start')
	policyd_start
  ;;
'stop')
	policyd_stop
  ;;
'restart')
	policyd_restart
  ;;
*)
	echo "USAGE: $0 start|stop|restart"
	exit 1
  ;;
esac