imip-agent

Annotated tools/init.sh

886:8a3994e54ea4
2015-10-20 Paul Boddie Permit the selection of a same-day ending while still allowing time adjustments.
paul@634 1
#!/bin/sh
paul@634 2
paul@731 3
PROGNAME=`basename $0`
paul@731 4
paul@731 5
DEFAULT_USER=imip-agent
paul@731 6
DEFAULT_GROUP=lmtp
paul@731 7
DEFAULT_INSTALL_DIR=/var/lib/imip-agent
paul@731 8
DEFAULT_WEB_INSTALL_DIR=/var/www/imip-agent
paul@731 9
paul@731 10
if [ "$1" = "--help" ]; then
paul@731 11
    cat 1>&2 <<EOF
paul@731 12
Usage: $PROGNAME [ <user> [ <group> [ <stored data directory> [ <published data directory> ] ] ] ]
paul@731 13
paul@731 14
Initialise stored and published data directories with permissions set to the
paul@731 15
given user and group (or, respectively, $DEFAULT_USER and $DEFAULT_GROUP if omitted),
paul@731 16
and with the given stored data and published data directories (or, respectively,
paul@731 17
$DEFAULT_INSTALL_DIR and $DEFAULT_WEB_INSTALL_DIR if omitted).
paul@731 18
paul@731 19
Within the stored data directory, the following directories are created:
paul@731 20
paul@731 21
  * $DEFAULT_INSTALL_DIR/store
paul@731 22
  * $DEFAULT_INSTALL_DIR/preferences
paul@731 23
paul@731 24
Within the published data directory, the following directory is created:
paul@731 25
paul@731 26
  * $DEFAULT_WEB_INSTALL_DIR/static
paul@731 27
EOF
paul@731 28
    exit 1
paul@731 29
fi
paul@731 30
paul@731 31
USER=${1:-$DEFAULT_USER}
paul@731 32
GROUP=${2:-$DEFAULT_GROUP}
paul@731 33
INSTALL_DIR=${3:-$DEFAULT_INSTALL_DIR}
paul@731 34
WEB_INSTALL_DIR=${4:-$DEFAULT_WEB_INSTALL_DIR}
paul@634 35
paul@634 36
for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do
paul@634 37
    mkdir -p "$DIR"
paul@634 38
    chown "$USER" "$DIR"
paul@634 39
    chgrp "$GROUP" "$DIR"
paul@634 40
    chmod g+ws "$DIR"
paul@634 41
done