1.1 --- a/tools/init.sh Sat Sep 12 20:16:38 2015 +0200
1.2 +++ b/tools/init.sh Sun Sep 13 00:50:38 2015 +0200
1.3 @@ -1,9 +1,37 @@
1.4 #!/bin/sh
1.5
1.6 -USER=imip-agent
1.7 -GROUP=lmtp
1.8 -INSTALL_DIR=/var/lib/imip-agent
1.9 -WEB_INSTALL_DIR=/var/www/imip-agent
1.10 +PROGNAME=`basename $0`
1.11 +
1.12 +DEFAULT_USER=imip-agent
1.13 +DEFAULT_GROUP=lmtp
1.14 +DEFAULT_INSTALL_DIR=/var/lib/imip-agent
1.15 +DEFAULT_WEB_INSTALL_DIR=/var/www/imip-agent
1.16 +
1.17 +if [ "$1" = "--help" ]; then
1.18 + cat 1>&2 <<EOF
1.19 +Usage: $PROGNAME [ <user> [ <group> [ <stored data directory> [ <published data directory> ] ] ] ]
1.20 +
1.21 +Initialise stored and published data directories with permissions set to the
1.22 +given user and group (or, respectively, $DEFAULT_USER and $DEFAULT_GROUP if omitted),
1.23 +and with the given stored data and published data directories (or, respectively,
1.24 +$DEFAULT_INSTALL_DIR and $DEFAULT_WEB_INSTALL_DIR if omitted).
1.25 +
1.26 +Within the stored data directory, the following directories are created:
1.27 +
1.28 + * $DEFAULT_INSTALL_DIR/store
1.29 + * $DEFAULT_INSTALL_DIR/preferences
1.30 +
1.31 +Within the published data directory, the following directory is created:
1.32 +
1.33 + * $DEFAULT_WEB_INSTALL_DIR/static
1.34 +EOF
1.35 + exit 1
1.36 +fi
1.37 +
1.38 +USER=${1:-$DEFAULT_USER}
1.39 +GROUP=${2:-$DEFAULT_GROUP}
1.40 +INSTALL_DIR=${3:-$DEFAULT_INSTALL_DIR}
1.41 +WEB_INSTALL_DIR=${4:-$DEFAULT_WEB_INSTALL_DIR}
1.42
1.43 for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do
1.44 mkdir -p "$DIR"