forked from roehling/postsrsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostsrsd.lsb_init.in
99 lines (88 loc) · 2.12 KB
/
postsrsd.lsb_init.in
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /bin/sh
#
# @PROJECT_NAME@
# start/stop the @PROJECT_NAME@ daemon for Postfix
#
### BEGIN INIT INFO
# Provides: @PROJECT_NAME@
# Required-Start: $syslog $network $local_fs
# Required-Stop: $syslog $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop the @PROJECT_NAME@ daemon
### END INIT INFO
set -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@
NAME=@PROJECT_NAME@
DESC="Postfix Sender Rewriting Scheme daemon"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
# Default configuration
SRS_DOMAIN=`postconf -h mydomain || true`
SRS_FORWARD_PORT=10001
SRS_REVERSE_PORT=10002
SRS_SECRET=@SYSCONF_DIR@/@[email protected]
RUN_AS=nobody
CHROOT=@CHROOT_DIR@
# Read config file if it is present.
if [ -r @CONFIG_DIR@/$NAME ]
then
. @CONFIG_DIR@/$NAME
fi
test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
ret=0
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon --start --oknodo --quiet \
--pidfile $PIDFILE \
--name $NAME \
--startas $DAEMON \
-- -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
then
log_end_msg 0
else
ret=$?
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --stop --oknodo --quiet \
--pidfile $PIDFILE --name $NAME
then
log_end_msg 0
else
ret=$?
log_end_msg 1
fi
rm -f $PIDFILE
;;
reload|force-reload|restart)
$0 stop
$0 start
ret=$?
;;
status)
log_daemon_msg "postsrsd is running"
if [ -s $PIDFILE ]; then
PID=`cat $PIDFILE`
if kill -0 "$PID" 2>/dev/null; then
log_end_msg 0
else
log_end_msg 1
fi
else
log_end_msg 1
fi
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
exit 1
;;
esac
exit $ret