diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-11-04 13:50:03 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-11-04 13:50:03 +0000 |
commit | 178200895e3b849eb0472dba04e95085599784bc (patch) | |
tree | 4ccd8a24fb228be32c7c22a418ea3a96ea246535 /etc | |
parent | df8dc30cc543806f4a7a3d2a1f71bf0904308f35 (diff) | |
download | mailfromd-178200895e3b849eb0472dba04e95085599784bc.tar.gz mailfromd-178200895e3b849eb0472dba04e95085599784bc.tar.bz2 |
New option `macros'.
git-svn-id: file:///svnroot/mailfromd/trunk@782 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.in | 105 |
1 files changed, 95 insertions, 10 deletions
@@ -43,16 +43,16 @@ mailfromd_stop() { N=0 while [ -r $PIDFILE ] do - N=$((N+1)) - if [ $N -gt 5 ]; then - break - fi - sleep 1 + N=$((N+1)) + if [ $N -gt 5 ]; then + break + fi + sleep 1 done if [ -r $PIDFILE ]; then - echo "Still running. Killing it..." >&2 - kill -KILL $PID 2>/dev/null - rm $PIDFILE + echo "Still running. Killing it..." >&2 + kill -KILL $PID 2>/dev/null + rm $PIDFILE fi else echo "mailfromd is not running" >&2 @@ -70,6 +70,67 @@ mailfromd_status() { done } +mailfromd_configtest() { + case $# in + 0) CFGOPT=;; + 1) CFGOPT=$1;; + *) echo "$0: too many arguments, try \`$0 help' for more info" >&2 + exit 1;; + esac + $DAEMON $CFGOPT --lint +} + +export_cf_macros() { + echo "O Milter.macros.$1=$2" +} + +export_mc_macros() { + un=`echo $1 | tr a-z A-Z` + echo "define(\`confMILTER_MACROS_$un', ifdef(\`confMILTER_MACROS_$un',\`confMILTER_MACROS_$un\`,' ')\`$2')" +} + + +mailfromd_macros() { + EXPORT=export_mc_macros + CFGOPT= + while [ $# -ne 0 ] + do + case $1 in + -c|--cf) EXPORT=export_cf_macros; shift;; + --) shift; break;; + -*) echo "$0: unknown command line option: $1" >&2; exit 1;; + *) if [ $# -eq 1 ]; then + if [ -r $1 ]; then + CFGOPT="-c $1" + else + echo "$0: \`$1' does not exist or is unreadable" >&2 + exit 1 + fi + break + else + echo "$0: too many arguments, try \`$0 help' for more info" >&2 + exit 1 + fi;; + esac + done + + IOUTPUT= + $DAEMON $CFGOPT --dump-macros | + while read state rest + do + if [ -z "$IOTPUT" ]; then + if [ "$state" != "helo" ]; then + $EXPORT helo i + else + rest="i, $rest" + fi + IOTPUT=yes + fi + $EXPORT $state "$rest" + done + exit 0 +} + case $1 in start) mailfromd_start;; stop) mailfromd_stop;; @@ -80,8 +141,32 @@ restart) status) mailfromd_status;; configtest) - $DAEMON --lint;; -*) echo "Usage: $0 {start|stop|restart|status|configtest}" >&2;; + shift + mailfromd_configtest $@;; +macros) + shift + mailfromd_macros $@;; +help) cat <<EOT +usage: $0 COMMAND [OPTIONS] +COMMANDS are: + start Start the daemon. + stop Stop the running instance of the daemon. + restart Restart the daemon. + status Display status of the running instance. + configtest [FILE] Check configuration file syntax. If FILE is not + given, the default one is assumed. + macros [OPTIONS] [FILE] + Generate milter export statements for Sendmail + configuration files. Optional FILE specifies + alternative mailfromd configuration file. + OPTIONS are: + -c, --cf Generate output, suitable for sendmail.cf + file (by default, \`.mc' format is assumed). + +EOT + ;; +*) echo "Usage: $0 {start|stop|restart|status|configtest|macros}" >&2 + echo "Try \`$0 help' for more info" >&2 esac # End of rc.mailfromd |