1.1 --- a/tools/init.sh Wed Oct 21 00:27:36 2015 +0200
1.2 +++ b/tools/init.sh Wed Oct 21 14:59:43 2015 +0200
1.3 @@ -1,37 +1,43 @@
1.4 #!/bin/sh
1.5
1.6 +DIRNAME=`dirname $0`
1.7 +
1.8 +if [ -e "$DIRNAME/config.sh" ]; then
1.9 + . "$DIRNAME/config.sh"
1.10 +else
1.11 + . /etc/imip-agent/config.sh
1.12 +fi
1.13 +
1.14 PROGNAME=`basename $0`
1.15
1.16 -DEFAULT_USER=imip-agent
1.17 -DEFAULT_GROUP=lmtp
1.18 -DEFAULT_INSTALL_DIR=/var/lib/imip-agent
1.19 -DEFAULT_WEB_INSTALL_DIR=/var/www/imip-agent
1.20 -
1.21 if [ "$1" = "--help" ]; then
1.22 cat 1>&2 <<EOF
1.23 -Usage: $PROGNAME [ <user> [ <group> [ <stored data directory> [ <published data directory> ] ] ] ]
1.24 +Usage: $PROGNAME [ <stored data directory> [ <published data directory> [ <user> [ <group> ] ] ] ]
1.25
1.26 -Initialise stored and published data directories with permissions set to the
1.27 -given user and group (or, respectively, $DEFAULT_USER and $DEFAULT_GROUP if omitted),
1.28 -and with the given stored data and published data directories (or, respectively,
1.29 -$DEFAULT_INSTALL_DIR and $DEFAULT_WEB_INSTALL_DIR if omitted).
1.30 +Initialise stored and published data directories either at any specified
1.31 +locations or, respectively, at $INSTALL_DIR and $WEB_INSTALL_DIR.
1.32 +
1.33 +Set permissions to the given user and group or, respectively, to $IMIP_AGENT_USER
1.34 +and $IMIP_AGENT_GROUP.
1.35
1.36 -Within the stored data directory, the following directories are created:
1.37 +Within the stored data directory (using $INSTALL_DIR as an example), the
1.38 +following directories are created:
1.39
1.40 - * $DEFAULT_INSTALL_DIR/store
1.41 - * $DEFAULT_INSTALL_DIR/preferences
1.42 + * $INSTALL_DIR/store
1.43 + * $INSTALL_DIR/preferences
1.44
1.45 -Within the published data directory, the following directory is created:
1.46 +Within the published data directory (using $WEB_INSTALL_DIR as an example), the
1.47 +following directory is created:
1.48
1.49 - * $DEFAULT_WEB_INSTALL_DIR/static
1.50 + * $WEB_INSTALL_DIR/static
1.51 EOF
1.52 exit 1
1.53 fi
1.54
1.55 -USER=${1:-$DEFAULT_USER}
1.56 -GROUP=${2:-$DEFAULT_GROUP}
1.57 -INSTALL_DIR=${3:-$DEFAULT_INSTALL_DIR}
1.58 -WEB_INSTALL_DIR=${4:-$DEFAULT_WEB_INSTALL_DIR}
1.59 +INSTALL_DIR=${1:-$INSTALL_DIR}
1.60 +WEB_INSTALL_DIR=${2:-$WEB_INSTALL_DIR}
1.61 +USER=${3:-$IMIP_AGENT_USER}
1.62 +GROUP=${4:-$IMIP_AGENT_GROUP}
1.63
1.64 for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do
1.65 mkdir -p "$DIR"