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