1 #!/bin/sh 2 3 DIRNAME=`dirname "$0"` 4 PROGNAME=`basename "$0"` 5 6 if [ "$1" = '--help' ] || [ ! "$1" ] || [ ! "$2" ]; then 7 cat 1>&2 <<EOF 8 Usage: $PROGNAME <definitions file> <output directory> [ <configuration> ] 9 10 Produce files to configure imip-agent using the definitions in the specified 11 file, storing the configuration files in the given output directory. This 12 utility is intended to make the customisation of the example configuration files 13 easier. 14 15 Once the files have been generated, they may be reviewed and copied into the 16 appropriate locations. 17 EOF 18 exit 1 19 fi 20 21 DEFSFILE=$1 22 OUTDIR=$2 23 CONF=${3:-"conf"} 24 25 if [ ! -e "$DEFSFILE" ]; then 26 cat 1>&2 <<EOF 27 The specified definitions file $DEFSFILE does not exist. 28 EOF 29 exit 1 30 fi 31 32 if [ ! -e "$CONF" ]; then 33 cat 1>&2 <<EOF 34 The conf directory cannot be found. 35 EOF 36 exit 1 37 fi 38 39 # Obtain the definitions. 40 41 . "$DEFSFILE" 42 43 # Configure the components. 44 45 for COMPONENT in apache exim postfix ; do 46 CONFDIR="$CONF/$COMPONENT" 47 48 for FILENAME in `find "$CONFDIR" -type f` ; do 49 PARENT="$OUTDIR/"`dirname "$FILENAME"` 50 if [ ! -e "$PARENT" ]; then 51 mkdir -p "$PARENT" 52 fi 53 54 envsubst "$SUBSTITUTED" < "$FILENAME" > "$OUTDIR/$FILENAME" 55 done 56 done