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