summaryrefslogtreecommitdiff
path: root/network/dbmail/rc.dbmail-pop3d.new
blob: 6398c40c8f00689decd8a2b2fb78e71e33c291b2 (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
#!/bin/sh
#
# DBMail-pop3d startup script for Slackware Linux

SERVICE='/usr/sbin/dbmail-pop3d'
OPTS=''
PIDDIR='/var/run/dbmail'
PID="${PIDDIR}/dbmail-pop3d.pid"
USER='mail'
GROUP='mail'

service_start() {
	if [ ! -d "$PIDDIR" ]; then
		mkdir "$PIDDIR"
		chown ${USER}:${GROUP} "$PIDDIR"
	fi

	if [ -f "$PID" ]; then
		echo "PID-file exist, refusing to run ${SERVICE}."
		exit 1
	fi

	$SERVICE "$OPTS"
}

service_stop() {
	if [ -f "$PID" ]; then
		kill $(< $PID)
	else
		echo "No PID-file at $PID found, quitting."
		exit 1
	fi
}

service_restart() {
  service_stop
  sleep 1
  service_start
}

case "$1" in
  start)
    service_start
    ;;
  stop)
    service_stop
    ;;
  restart)
    service_restart
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac