~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/proxsmtp

  • Committer: Dimitri John Ledkov
  • Date: 2014-05-06 18:45:46 UTC
  • Revision ID: dimitri.ledkov@canonical.com-20140506184546-5toyx56xxrue0f0v
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh -e
 
2
### BEGIN INIT INFO
 
3
# Provides:             proxsmtp
 
4
# Required-Start:       $syslog $network $remote_fs
 
5
# Required-Stop:        $syslog $network $remote_fs
 
6
# Default-Start:        2 3 4 5
 
7
# Default-Stop:         0 1 6
 
8
# Short-Description:    Start the proxsmtp proxies
 
9
# Description:          Start all the proxsmtp proxies from /etc/proxsmtp/*.conf
 
10
### END INIT INFO
 
11
 
 
12
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
13
NAME=proxsmtp
 
14
DAEMON=/usr/sbin/proxsmtpd
 
15
 
 
16
 . /lib/lsb/init-functions
 
17
 
 
18
lsconfs() {
 
19
    ls /etc/$NAME/*.conf 2>/dev/null
 
20
}
 
21
 
 
22
# Gracefully exit if the package has been removed.
 
23
test -x $DAEMON || exit 0
 
24
 
 
25
mkdir -p /var/run/proxsmtp
 
26
 
 
27
# Gracefully exit if there is no available config files
 
28
lsconfs > /dev/null || exit 0
 
29
 
 
30
d_start() {
 
31
    start_daemon -p "$1" $DAEMON -p "$1" -f "$2"
 
32
}
 
33
 
 
34
d_stop() {
 
35
    killproc -p "$1" `basename $DAEMON`
 
36
}
 
37
 
 
38
d_all() {
 
39
    cmd="$2"
 
40
 
 
41
    log_daemon_msg "$1 smtp proxies"
 
42
    lsconfs | while read conf; do
 
43
        inst=`basename "$conf" .conf`
 
44
 
 
45
        log_progress_msg "$inst"
 
46
        $cmd "/var/run/$NAME/$inst.pid" "$conf"
 
47
    done
 
48
    log_end_msg 0
 
49
}
 
50
 
 
51
case "$1" in
 
52
    start)
 
53
        d_all "Starting" d_start
 
54
        ;;
 
55
    stop)
 
56
        d_all "Stopping" d_stop
 
57
        ;;
 
58
    force-reload|restart)
 
59
        d_all "Stopping" d_stop
 
60
        d_all "Starting" d_start
 
61
        ;;
 
62
    *)
 
63
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
 
64
        exit 1
 
65
        ;;
 
66
esac
 
67
 
 
68
exit 0