aboutsummaryrefslogtreecommitdiff
path: root/network/exim/rc.exim.new
blob: 4902203dfb9061f9dbb15ab96e4584ee7844e3e6 (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
#!/bin/sh

# /etc/rc.d/rc.exim - start/stop/restart the exim mail transfer agent.
# To make exim start automatically at boot, make this
# file executable: chmod 755 /etc/rc.d/rc.exim
#
# Thales A. Tsailas <ttsailas@enforcingit.com>

PIDFILE=/var/run/exim.pid

# the TIME option causes Exim to run as a daemon, starting a queue runner 
# process at intervals specified by the given time value. (ie 5m, 1h etc).
TIME=15m

exim_start() {
    # Make sure that we have the right ownerships permissions.
    if [ -f /var/log/exim/main.log ]; then
        if [ "exim" != "$(/bin/stat -c%G /var/log/exim/main.log)" ]; then
            chown -R exim:exim /var/{log,spool}/exim
        fi
    fi
    
    # Lets start the Exim daemon
    echo -en "Starting exim... \n"
    /usr/sbin/exim -bd -q$TIME
}

exim_stop() {
    echo -en "Shutting down exim...\n"
    killall exim
    rm -f $PIDFILE
}

exim_status() {
    if [ -f /var/run/exim.pid ]; then
        echo "exim (pid: $(cat $PIDFILE) is running...";
    else 
        echo "exim is not running...";
    fi
}

# See how we were called.
case "$1" in
  start)
    exim_start
    ;;
  stop)
    exim_stop
    ;;
  restart)
    exim_stop
    sleep 2
    exim_start
    ;;
  status)
    status 
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
esac