blob: 1aaf9f74e737ea2b26bfff00fe5f8eac9c4ec977 (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: prayer.sh,v 1.3 2011/06/30 01:17:37 schnoebe Exp $
#
# This shell script takes care of starting and stopping prayer,
# a program providing web access to a mail server using IMAP
#
## only for NetBSD
# PROVIDE: prayer
# REQUIRE: LOGIN
# AFTER: mail
# KEYWORD: shutdown
##
PATH=/sbin:/bin:/usr/sbin:/usr/bin:@PREFIX@/sbin
export PATH
if [ -f /etc/rc.subr ]
then
. /etc/rc.subr
fi
name="prayer"
rcvar=$name
command="@PREFIX@/sbin/prayer"
command_args=""
pidfile="@VAR_PREFIX@/pid/prayer.pid"
prayer_flags=${prayer_flags-""}
OPSYS=@OPSYS@
get_prayer_pid()
{
if [ -f ${pidfile} ]; then
prayer_pid=$(head -1 ${pidfile})
if kill -0 ${prayer_pid} >/dev/null; then
:
else
prayer_pid=
fi
else
prayer_pid=
fi
}
prayer_start()
{
get_prayer_pid
if [ -n "${prayer_pid}" ]; then
echo "${command} already running as pid ${prayer_pid}."
return 1
fi
echo "Starting ${name}."
${command} ${prayer_flags} ${command_args}
}
prayer_stop()
{
get_prayer_pid
if [ -z "${prayer_pid}" ]; then
echo "${command} not running? (check ${pidfile})."
return 1
fi
echo "Stopping ${name}."
kill -HUP ${prayer_pid}
prayer_session_pid=$(cat @VAR_PREFIX@/pid/prayer-session.pid)
if [ -n "${prayer_session_pid}" ]; then
if kill -0 ${prayer_session_pid} >/dev/null; then
kill -HUP ${prayer_session_pid}
fi
fi
slaves=$(ps -U prayer| awk '/PID/ {next}; {print $1}')
kill -HUP $slaves
}
prayer_status()
{
get_prayer_pid
if [ -z "${prayer_pid}" ]; then
echo "${command} is not running? (check ${pidfile})."
else
echo "${command} is running as pid ${prayer_pid}."
fi
}
if [ "${OPSYS}" = "NetBSD" ]; then
stop_cmd=prayer_stop
load_rc_config $name
run_rc_command "$1"
else # not NetBSD
case ${1+"$@"} in
start)
prayer_start
;;
stop)
prayer_stop
;;
restart)
prayer_stop
sleep 2
prayer_start
;;
status)
prayer_status
;;
*)
echo "Usage: ${0} (start|stop|restart|status)"
;;
esac
fi
|