updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / dovecot-systemd / dovecot.sh
blobe8966bd55c421c9a6f7fe678b59c09eb607eed1a
1 #!/bin/bash
3 daemon_name=dovecot
5 . /etc/rc.conf
6 . /etc/rc.d/functions
7 #. /etc/conf.d/$daemon_name.conf
9 get_pid() {
10 pidof -o %PPID $daemon_name
13 case "$1" in
14 start)
15 stat_busy "Starting $daemon_name daemon"
17 PID=$(get_pid)
18 if [[ -z $PID ]]; then
19 [[ -f /var/run/$daemon_name.pid ]] &&
20 rm -f /var/run/$daemon_name.pid
21 # RUN
22 $daemon_name
24 if [[ $? -gt 0 ]]; then
25 stat_fail
26 exit 1
27 else
28 echo $(get_pid) > /var/run/$daemon_name.pid
29 add_daemon $daemon_name
30 stat_done
32 else
33 stat_fail
34 exit 1
38 stop)
39 stat_busy "Stopping $daemon_name daemon"
40 PID=$(get_pid)
41 # KILL
42 [[ -n $PID ]] && kill $PID &> /dev/null
44 if [[ $? -gt 0 ]]; then
45 stat_fail
46 exit 1
47 else
48 rm -f /var/run/$daemon_name.pid &> /dev/null
49 rm_daemon $daemon_name
50 stat_done
54 restart)
55 $0 stop
56 sleep 3
57 $0 start
60 status)
61 stat_busy "Checking $daemon_name status";
62 ck_status $daemon_name
66 echo "usage: $0 {start|stop|restart|status}"
67 esac
69 exit 0