Created
August 15, 2014 07:11
-
-
Save briceburg/e76d93e77afc4988ecc2 to your computer and use it in GitHub Desktop.
CentOS / RedHat LSB init script for nullmailer MTA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# nullmailer MTA | |
# | |
# chkconfig: - 85 15 | |
# description: nullmailer centos init @iceburg_net | |
### BEGIN INIT INFO | |
# Provides: smtpdaemon | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: | |
# Description: | |
### END INIT INFO | |
# Source function library. | |
. /etc/init.d/functions | |
RETVAL=0 | |
prog=nullmailer | |
exec=/usr/sbin/nullmailer-send | |
lockfile=/var/lock/subsys/$prog | |
run_as=nullmail | |
logfile=/var/log/nullmailer/nullmailer.log | |
# Source config | |
if [ -f /etc/sysconfig/$prog ] ; then | |
. /etc/sysconfig/$prog | |
fi | |
start() { | |
[ -x $exec ] || exit 5 | |
echo -n "Starting $prog: " | |
PIDS=`pidof -c $exec` | |
if [ -z "$PIDS" ]; then | |
# modified to use a double-fork technique in absence of start-stop-daemon... | |
runuser -s /bin/bash $run_as -c "((exec $exec >> $logfile 2>&1)&)" | |
RETVAL=$? | |
else | |
echo -n "$prog is already running" | |
RETVAL=1 | |
fi | |
[ $RETVAL -eq 0 ] && touch $lockfile && success || failure | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Stopping $prog: " | |
PIDS=`pidof -c $exec` | |
if [ -n "$PIDS" ]; then | |
killall $exec | |
return $? | |
else | |
echo -n "$prog is not running" | |
RETVAL=1 | |
fi | |
[ $RETVAL -eq 0 ] && rm -f $lockfile && success || failure | |
echo | |
return $RETVAL | |
} | |
status() { | |
echo -n "status not supported " | |
return 0 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $NAME {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment