File: init

package info (click to toggle)
proxsmtp 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 756 kB
  • ctags: 315
  • sloc: sh: 3,737; ansic: 3,423; makefile: 14
file content (68 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download
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
#! /bin/sh -e
### BEGIN INIT INFO
# Provides:             proxsmtp
# Required-Start:       $syslog $network
# Required-Stop:        $syslog $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Start the proxsmtp proxies
# Description:          Start all the proxsmtp proxies from /etc/proxsmtp/*.conf
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=proxsmtp
DAEMON=/usr/sbin/proxsmtpd

 . /lib/lsb/init-functions

lsconfs() {
    ls /etc/$NAME/*.conf 2>/dev/null
}

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

mkdir -p /var/run/proxsmtp

# Gracefully exit if there is no available config files
lsconfs > /dev/null || exit 0

d_start() {
    start_daemon -p "$1" $DAEMON -p "$1" -f "$2"
}

d_stop() {
    killproc -p "$1" `basename $DAEMON`
}

d_all() {
    cmd="$2"

    log_daemon_msg "$1 smtp proxies"
    lsconfs | while read conf; do
        inst=`basename "$conf" .conf`

        log_progress_msg "$inst"
        $cmd "/var/run/$NAME/$inst.pid" "$conf"
    done
    log_end_msg 0
}

case "$1" in
    start)
        d_all "Starting" d_start
	;;
    stop)
        d_all "Stopping" d_stop
        ;;
    force-reload|restart)
        d_all "Stopping" d_stop
        d_all "Starting" d_start
	;;
    *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0