mirror of
https://github.com/darold/sendmailanalyzer.git
synced 2026-05-16 06:05:53 -06:00
88 lines
2.1 KiB
Bash
88 lines
2.1 KiB
Bash
#!/bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: sendmailanalyzer
|
|
# Required-Start: $local_fs $remote_fs $network $syslog $named
|
|
# Required-Stop: $local_fs $remote_fs $network $syslog $named
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start/stop sendmailanalyzer server
|
|
### END INIT INFO
|
|
|
|
#
|
|
# Start/stop/restart SendmailAnalyzer.
|
|
#
|
|
|
|
NAME=sendmailanalyzer
|
|
DAEMON=/usr/bin/sendmailanalyzer
|
|
PIDFILE=/var/run/sendmailanalyzer.pid
|
|
DESC="Sendmail Analyzer"
|
|
OPTIONS="-f"
|
|
|
|
# Exit if the package is not installed
|
|
[ -x "$DAEMON" ] || exit 0
|
|
|
|
# Read configuration variable file if it is present
|
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
|
|
|
# Define LSB log_* functions.
|
|
. /lib/lsb/init-functions
|
|
|
|
# Start SendmailAnalyzer:
|
|
sa_start() {
|
|
# Return
|
|
# 0 if daemon has been started
|
|
# 1 if daemon was already running
|
|
# other if daemon could not be started or a failure occured
|
|
start-stop-daemon --status --pidfile $PIDFILE
|
|
[ $? -eq 0 ] && return 1
|
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS
|
|
}
|
|
|
|
# Stop SendmailAnalyzer:
|
|
sa_stop() {
|
|
# Return
|
|
# 0 if daemon has been stopped
|
|
# 1 if daemon was already stopped
|
|
# other if daemon could not be stopped or a failure occurred
|
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
|
|
}
|
|
|
|
# Restart SendmailAnalyzer:
|
|
sa_restart() {
|
|
sa_stop
|
|
sleep 2
|
|
sa_start
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
log_daemon_msg "Starting $DESC" "$NAME"
|
|
sa_start
|
|
case "$?" in
|
|
0) log_end_msg 0 ;;
|
|
1) log_progress_msg "already started"
|
|
log_end_msg 0 ;;
|
|
*) log_end_msg 1 ;;
|
|
esac
|
|
;;
|
|
stop)
|
|
log_daemon_msg "Stopping $DESC" "$NAME"
|
|
sa_stop
|
|
case "$?" in
|
|
0) log_end_msg 0 ;;
|
|
1) log_progress_msg "already stopped"
|
|
log_end_msg 0 ;;
|
|
*) log_end_msg 1 ;;
|
|
esac
|
|
|
|
;;
|
|
restart|force-reload)
|
|
$0 stop
|
|
$0 start
|
|
;;
|
|
*)
|
|
echo "usage $0 start|stop|force-reload|restart"
|
|
exit 3
|
|
;;
|
|
esac
|
|
|