From 16262790cb6ddacf6c632625cc865e03b1b8671f Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 25 Nov 2012 21:24:58 +0100 Subject: rcdscripts: import first snapshot of rc.d scripts as of 11.25.2012 In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable. --- src/postgrey/postgrey.rc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 src/postgrey/postgrey.rc (limited to 'src/postgrey') diff --git a/src/postgrey/postgrey.rc b/src/postgrey/postgrey.rc new file mode 100755 index 0000000..dc25887 --- /dev/null +++ b/src/postgrey/postgrey.rc @@ -0,0 +1,74 @@ +#!/bin/bash + +# source application-specific settings +POSTGREY_CONF=/etc/conf.d/postgrey +[ -f $POSTGREY_CONF ] && . $POSTGREY_CONF + +. /etc/rc.conf +. /etc/rc.d/functions + +GROUP="postgrey" +USER="postgrey" +DAEMON_NAME="postgrey" +POSTGREY_BIN="/usr/sbin/postgrey" +PIDFILE=/var/run/postgrey/postgrey.pid + +mkdir -p /var/run/postgrey +chown $USER:$GROUP /var/run/postgrey + +PID=`cat $PIDFILE 2>/dev/null` +[ -d /proc/$PID ] || PID="" + +checkconfig() { + if [ -z $POSTGREY_ADDR ]; then + echo "You need to set POSTGREY_ADDR instead of POSTGREY_TYPE parameter bundle" + return 1 + fi +} + +start() { + stat_busy "Starting Postgrey" + checkconfig || { stat_fail; return 1; } + + [ -z "$PID" ] && $POSTGREY_BIN --daemonize $POSTGREY_ADDR \ + --group=$GROUP --user=$USER $POSTGREY_OPTS --pidfile=$PIDFILE \ + --greylist-text="$POSTGREY_TEXT" > /dev/null + + if [ $? -gt 0 ] + then + stat_fail + else + add_daemon postgrey + stat_done + fi +} + +stop() { + stat_busy "Stopping Postgrey" + [ ! -z "$PID" ] && kill -9 $PID &> /dev/null + if [ $? -gt 0 ] + then + stat_fail + else + rm_daemon postgrey + rm -f $PIDFILE + stat_done + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + # calling 'stop' and 'start' without the $0 fails... + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" + esac +exit 0 -- cgit v1.2.3