1 #!/bin/sh 2 3 DIRNAME=`dirname "$0"` 4 5 if [ -e "$DIRNAME/config.sh" ]; then 6 CONFIG="$DIRNAME/config.sh" 7 . "$CONFIG" 8 else 9 CONFIG=/etc/imip-agent/config.sh 10 . "$CONFIG" 11 fi 12 13 PROGNAME=`basename "$0"` 14 15 if [ "$1" = "--help" ] || [ ! "$1" ]; then 16 cat 1>&2 <<EOF 17 Usage: $PROGNAME <calendar user> 18 19 Initialise a given calendar user within an existing installation, creating 20 resources within the given stored data and published data directories... 21 22 * $INSTALL_DIR 23 * $WEB_INSTALL_DIR 24 25 ...respectively. 26 27 The resources will be defined as having $IMIP_AGENT_USER as owner. 28 29 See $CONFIG for the settings used as described above. 30 31 Example: 32 33 $PROGNAME mailto:vincent.vole@example.com 34 EOF 35 exit 1 36 fi 37 38 CALENDAR_USER=$1 39 40 if [ ! "$CALENDAR_USER" ]; then 41 cat 1>&2 <<EOF 42 Need a calendar user to initialise. 43 EOF 44 exit 1 45 fi 46 47 # Test for a privileged user. 48 49 if [ `whoami` != 'root' ]; then 50 cat 1>&2 <<EOF 51 You will need to become a privileged user using su or sudo to run this program 52 because it changes file ownership. 53 EOF 54 exit 1 55 fi 56 57 # Initialise the directories. 58 59 echo "Creating preferences and static Web directories..." 1>&2 60 61 for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do 62 mkdir -p "$DIR/$CALENDAR_USER" 63 chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER" 64 chmod g+ws "$DIR/$CALENDAR_USER" 65 # Group privileges should already be set. 66 done 67 68 if [ "$STORE_TYPE" = "file" ]; then 69 70 echo "Creating store and journal directories..." 1>&2 71 72 for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do 73 mkdir -p "$DIR/$CALENDAR_USER" 74 chown "$IMIP_AGENT_USER" "$DIR/$CALENDAR_USER" 75 chmod g+ws "$DIR/$CALENDAR_USER" 76 # Group privileges should already be set. 77 done 78 fi