#!/usr/sbin/sh # # Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. DEFAULT_FILE="/etc/default/sendmail" SENDMAIL="/usr/lib/sendmail" PATH="/usr/bin:/usr/sbin" export PATH check_queue_interval_syntax() { default="15m" if [ $# -lt 1 ]; then answer=$default return fi if echo $1 | egrep '^([0-9]*[1-9][0-9]*[smhdw])+$' >/dev/null 2>&1; then answer=$1 else answer=$default fi } check_and_kill() { PID=`head -1 $1` kill -0 $PID > /dev/null 2>&1 [ $? -eq 0 ] && kill $PID } exist_or_exit() { if [ ! -f $1 ]; then echo "$1 does not exist" >&2 exit $SMF_EXIT_ERR_CONFIG fi } turn_m4_crank() { # expected to be called with two arguments: .cf path & path to m4 file [ $# -lt 2 ] && return cf_path=$1 m4_path=$2 if [ "$m4_path" = "_DONT_TOUCH_THIS" ]; then if [ -f "${cf_path}.old" ]; then mv "$cf_path" "${cf_path}.new" [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG mv "${cf_path}.old" "$cf_path" [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG fi # # If ${cf_path}.old does not exist, assume it was taken care # of on a previous run. # else case "$m4_path" in /*) ;; # absolute path *) return;; esac exist_or_exit "$m4_path" if [[ $cf_path -nt $m4_path || $cf_path -ot $m4_path ]] ; then # fall through : else return fi # just in case the file tries to include files with a relative path cd `dirname "$m4_path"` || echo "Warning: Can't cd to "`dirname "$m4_path"`" (this may produce unexpected results)" info=`svcprop -p config/include_info $SMF_FMRI 2>/dev/null` if [ "$info" = "true" ]; then m4flags="" else m4flags="-DSUN_HIDE_INTERNAL_DETAILS" fi m4 -D_CF_DIR_=/etc/mail/cf/ $m4flags /etc/mail/cf/m4/cf.m4 "$m4_path" \ > "${cf_path}.new" [[ $? -ne 0 || ! -s "${cf_path}.new" ]] && exit $SMF_EXIT_ERR_CONFIG cmp -s "${cf_path}.new" "$cf_path" || ( chown root:bin "${cf_path}.new" && chmod 444 "${cf_path}.new" && mv "${cf_path}.new" "$cf_path" ) [ $? -ne 0 ] && exit $SMF_EXIT_ERR_CONFIG touch -r "$m4_path" "$cf_path" fi }