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@1135 | 30 | |
paul@1135 | 31 | Example: |
paul@1135 | 32 | |
paul@1135 | 33 | $PROGNAME mailto:vincent.vole@example.com |
paul@752 | 34 | EOF |
paul@752 | 35 | exit 1 |
paul@752 | 36 | fi |
paul@752 | 37 | |
paul@891 | 38 | CALENDAR_USER=$1 |
paul@752 | 39 | |
paul@1096 | 40 | if [ ! "$CALENDAR_USER" ]; then |
paul@1096 | 41 | cat 1>&2 <<EOF |
paul@1096 | 42 | Need a calendar user to initialise. |
paul@1096 | 43 | EOF |
paul@1096 | 44 | exit 1 |
paul@1096 | 45 | fi |
paul@1096 | 46 | |
paul@1135 | 47 | # Test for a privileged user. |
paul@1135 | 48 | |
paul@1135 | 49 | if [ `whoami` != 'root' ]; then |
paul@1135 | 50 | cat 1>&2 <<EOF |
paul@1135 | 51 | You will need to become a privileged user using su or sudo to run this program |
paul@1135 | 52 | because it changes file ownership. |
paul@1135 | 53 | EOF |
paul@1135 | 54 | exit 1 |
paul@1135 | 55 | fi |
paul@1135 | 56 | |
paul@1096 | 57 | # Initialise the directories. |
paul@752 | 58 | |
paul@1135 | 59 | echo "Creating preferences and static Web directories..." 1>&2 |
paul@1135 | 60 | |
paul@1089 | 61 | for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do |
paul@752 | 62 | mkdir -p "$DIR/$CALENDAR_USER" |
paul@1096 | 63 | chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER" |
paul@752 | 64 | chmod g+ws "$DIR/$CALENDAR_USER" |
paul@752 | 65 | # Group privileges should already be set. |
paul@752 | 66 | done |
paul@1089 | 67 | |
paul@1089 | 68 | if [ "$STORE_TYPE" = "file" ]; then |
paul@1135 | 69 | |
paul@1135 | 70 | echo "Creating store and journal directories..." 1>&2 |
paul@1135 | 71 | |
paul@1089 | 72 | for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do |
paul@1089 | 73 | mkdir -p "$DIR/$CALENDAR_USER" |
paul@1096 | 74 | chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER" |
paul@1089 | 75 | chmod g+ws "$DIR/$CALENDAR_USER" |
paul@1089 | 76 | # Group privileges should already be set. |
paul@1089 | 77 | done |
paul@1089 | 78 | fi |