Imported Debian patch 0.63.0-6
[hcoop/debian/courier-authlib.git] / debian / courier-authdaemon.init
1 #! /bin/sh -e
2 #
3 ### BEGIN INIT INFO
4 # Provides: courier-authdaemon
5 # Required-Start: $remote_fs $syslog
6 # Required-Stop: $remote_fs $syslog
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 ### END INIT INFO
10
11 prefix="/usr"
12 exec_prefix=${prefix}
13 sysconfdir="/etc/courier"
14 sbindir="${exec_prefix}/sbin"
15 daemonscript="${sbindir}/authdaemond"
16 rundir_courier="/var/run/courier"
17 rundir="/var/run/courier/authdaemon"
18 pidfile="${rundir}/pid"
19
20 . /lib/lsb/init-functions
21
22 # Check for a leftover init script
23 if [ ! -x $daemonscript ]; then
24 exit 0
25 fi
26
27 case "$1" in
28 start)
29 # Start daemon.
30 cd /
31 log_daemon_msg "Starting Courier authentication services" "authdaemond"
32 if [ ! -d "$rundir_courier" ]; then
33 mkdir -m 0775 $rundir_courier
34 chown daemon:daemon $rundir_courier
35 # set file context for SELinux (#668564)
36 [ -x /sbin/restorecon ] && /sbin/restorecon $rundir_courier
37 fi
38 if [ ! -d "$rundir" ]; then
39 mkdir -m 0750 $rundir
40 chown daemon:daemon $rundir
41 # set file context for SELinux (#668564)
42 [ -x /sbin/restorecon ] && /sbin/restorecon $rundir
43 fi
44 $daemonscript start
45 log_end_msg 0
46 ;;
47 stop)
48 # Stop daemon.
49 cd /
50 log_daemon_msg "Stopping Courier authentication services" "authdaemond"
51 $daemonscript stop
52 log_end_msg 0
53 ;;
54 restart|force-reload)
55 $0 stop
56 $0 start
57 ;;
58 status)
59 status_of_proc -p "$pidfile" "" "authdaemond" && exit 0 || exit $?
60 ;;
61 *)
62 echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
63 exit 2
64 ;;
65 esac
66 exit 0