paul@634 | 1 | #!/bin/sh |
paul@634 | 2 | |
paul@891 | 3 | DIRNAME=`dirname $0` |
paul@891 | 4 | |
paul@891 | 5 | if [ -e "$DIRNAME/config.sh" ]; then |
paul@1089 | 6 | CONFIG="$DIRNAME/config.sh" |
paul@1089 | 7 | . "$CONFIG" |
paul@891 | 8 | else |
paul@1089 | 9 | CONFIG=/etc/imip-agent/config.sh |
paul@1089 | 10 | . "$CONFIG" |
paul@891 | 11 | fi |
paul@891 | 12 | |
paul@731 | 13 | PROGNAME=`basename $0` |
paul@731 | 14 | |
paul@731 | 15 | if [ "$1" = "--help" ]; then |
paul@731 | 16 | cat 1>&2 <<EOF |
paul@891 | 17 | Usage: $PROGNAME [ <stored data directory> [ <published data directory> [ <user> [ <group> ] ] ] ] |
paul@731 | 18 | |
paul@891 | 19 | Initialise stored and published data directories either at any specified |
paul@891 | 20 | locations or, respectively, at $INSTALL_DIR and $WEB_INSTALL_DIR. |
paul@891 | 21 | |
paul@891 | 22 | Set permissions to the given user and group or, respectively, to $IMIP_AGENT_USER |
paul@891 | 23 | and $IMIP_AGENT_GROUP. |
paul@731 | 24 | |
paul@891 | 25 | Within the stored data directory (using $INSTALL_DIR as an example), the |
paul@891 | 26 | following directories are created: |
paul@731 | 27 | |
paul@1089 | 28 | * $INSTALL_DIR/journal (if STORE_TYPE is "file") |
paul@1039 | 29 | * $INSTALL_DIR/preferences |
paul@1089 | 30 | * $INSTALL_DIR/store (if STORE_TYPE is "file") |
paul@731 | 31 | |
paul@891 | 32 | Within the published data directory (using $WEB_INSTALL_DIR as an example), the |
paul@891 | 33 | following directory is created: |
paul@731 | 34 | |
paul@891 | 35 | * $WEB_INSTALL_DIR/static |
paul@1089 | 36 | |
paul@1089 | 37 | See $CONFIG for the STORE_TYPE setting. |
paul@731 | 38 | EOF |
paul@731 | 39 | exit 1 |
paul@731 | 40 | fi |
paul@731 | 41 | |
paul@891 | 42 | INSTALL_DIR=${1:-$INSTALL_DIR} |
paul@891 | 43 | WEB_INSTALL_DIR=${2:-$WEB_INSTALL_DIR} |
paul@891 | 44 | USER=${3:-$IMIP_AGENT_USER} |
paul@891 | 45 | GROUP=${4:-$IMIP_AGENT_GROUP} |
paul@634 | 46 | |
paul@1089 | 47 | for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do |
paul@634 | 48 | mkdir -p "$DIR" |
paul@634 | 49 | chown "$USER" "$DIR" |
paul@634 | 50 | chgrp "$GROUP" "$DIR" |
paul@634 | 51 | chmod g+ws "$DIR" |
paul@634 | 52 | done |
paul@1089 | 53 | |
paul@1089 | 54 | if [ "$STORE_TYPE" = "file" ]; then |
paul@1089 | 55 | for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do |
paul@1089 | 56 | mkdir -p "$DIR" |
paul@1089 | 57 | chown "$USER" "$DIR" |
paul@1089 | 58 | chgrp "$GROUP" "$DIR" |
paul@1089 | 59 | chmod g+ws "$DIR" |
paul@1089 | 60 | done |
paul@1089 | 61 | fi |