imip-agent

Annotated tools/init_user.sh

1113:cfbb32370151
2016-04-17 Paul Boddie Merged changes from the default branch. freebusy-collections
paul@752 1
#!/bin/sh
paul@752 2
paul@1108 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@1108 13
PROGNAME=`basename "$0"`
paul@752 14
paul@1108 15
if [ "$1" = "--help" ] || [ ! "$1" ]; then
paul@752 16
    cat 1>&2 <<EOF
paul@1096 17
Usage: $PROGNAME <calendar user>
paul@752 18
paul@891 19
Initialise a given calendar user within an existing installation, creating
paul@1096 20
resources within the given stored data and published data directories...
paul@1096 21
paul@1096 22
  * $INSTALL_DIR
paul@1096 23
  * $WEB_INSTALL_DIR
paul@891 24
paul@1096 25
...respectively.
paul@1096 26
paul@1096 27
The resources will be defined as having $IMIP_AGENT_USER as owner.
paul@1096 28
paul@1096 29
See $CONFIG for the settings used as described above.
paul@752 30
EOF
paul@752 31
    exit 1
paul@752 32
fi
paul@752 33
paul@891 34
CALENDAR_USER=$1
paul@752 35
paul@1096 36
if [ ! "$CALENDAR_USER" ]; then
paul@1096 37
    cat 1>&2 <<EOF
paul@1096 38
Need a calendar user to initialise.
paul@1096 39
EOF
paul@1096 40
    exit 1
paul@1096 41
fi
paul@1096 42
paul@1096 43
# Initialise the directories.
paul@752 44
paul@1089 45
for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do
paul@752 46
    mkdir -p "$DIR/$CALENDAR_USER"
paul@1096 47
    chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER"
paul@752 48
    chmod g+ws "$DIR/$CALENDAR_USER"
paul@752 49
    # Group privileges should already be set.
paul@752 50
done
paul@1089 51
paul@1089 52
if [ "$STORE_TYPE" = "file" ]; then
paul@1089 53
    for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do
paul@1089 54
        mkdir -p "$DIR/$CALENDAR_USER"
paul@1096 55
        chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER"
paul@1089 56
        chmod g+ws "$DIR/$CALENDAR_USER"
paul@1089 57
        # Group privileges should already be set.
paul@1089 58
    done
paul@1089 59
fi