imip-agent

Annotated tools/install.sh

1045:5a9722130d25
2016-02-08 Paul Boddie Used event-related attributes stored in the handler directly.
paul@102 1
#!/bin/sh
paul@102 2
paul@954 3
DIRNAME=`dirname $0`
paul@954 4
paul@954 5
if [ -e "$DIRNAME/config.sh" ]; then
paul@954 6
    . "$DIRNAME/config.sh"
paul@954 7
else
paul@954 8
    . /etc/imip-agent/config.sh
paul@954 9
fi
paul@954 10
paul@1008 11
if [ "$1" = "--no-locale-dir" ]; then
paul@1008 12
    NO_LOCALE_DIR=$1
paul@1008 13
else
paul@1008 14
    NO_LOCALE_DIR=
paul@1008 15
fi
paul@1008 16
paul@670 17
# Agents and modules.
paul@670 18
paul@102 19
AGENTS="imip_person.py imip_person_outgoing.py imip_resource.py"
paul@102 20
MODULES="markup.py imip_store.py vCalendar.py vContent.py vRecurrence.py"
paul@102 21
paul@102 22
if [ ! -e "$INSTALL_DIR" ]; then
paul@102 23
    mkdir -p "$INSTALL_DIR"
paul@102 24
fi
paul@102 25
paul@102 26
cp $AGENTS "$INSTALL_DIR"
paul@102 27
cp $MODULES "$INSTALL_DIR"
paul@440 28
paul@1028 29
for DIR in "$INSTALL_DIR/imiptools" \
paul@1028 30
           "$INSTALL_DIR/imiptools/handlers" \
paul@1028 31
           "$INSTALL_DIR/imiptools/handlers/scheduling" ; do
paul@1028 32
    if [ ! -e "$DIR" ]; then
paul@1028 33
        mkdir "$DIR"
paul@1028 34
    fi
paul@1028 35
done
paul@440 36
paul@671 37
# Remove any symbolic link to the config module.
paul@671 38
paul@671 39
if [ -h "$INSTALL_DIR/imiptools/config.py" ]; then
paul@671 40
    rm "$INSTALL_DIR/imiptools/config.py"
paul@671 41
fi
paul@671 42
paul@671 43
# Copy modules into the installation directory.
paul@671 44
paul@671 45
cp imiptools/*.py "$INSTALL_DIR/imiptools/"
paul@671 46
cp imiptools/handlers/*.py "$INSTALL_DIR/imiptools/handlers/"
paul@1028 47
cp imiptools/handlers/scheduling/*.py "$INSTALL_DIR/imiptools/handlers/scheduling/"
paul@1028 48
paul@1028 49
# Remove migrated modules.
paul@1028 50
paul@1028 51
if [ -e "$INSTALL_DIR/imiptools/handlers/scheduling.py" ]; then
paul@1028 52
    rm "$INSTALL_DIR/imiptools/handlers/scheduling.py"*
paul@1028 53
fi
paul@671 54
paul@671 55
# Install the config module in a more appropriate location.
paul@671 56
paul@671 57
if [ ! -e "$CONFIG_DIR" ]; then
paul@671 58
    mkdir -p "$CONFIG_DIR"
paul@671 59
fi
paul@671 60
paul@671 61
if [ -e "$CONFIG_DIR/config.py" ]; then
paul@671 62
    if [ ! -e "$CONFIG_DIR/config.py.backup" ]; then
paul@671 63
        mv "$CONFIG_DIR/config.py" "$CONFIG_DIR/config.py.backup"
paul@668 64
    fi
paul@668 65
fi
paul@668 66
paul@891 67
if [ -e "$CONFIG_DIR/config.sh" ]; then
paul@891 68
    if [ ! -e "$CONFIG_DIR/config.sh.backup" ]; then
paul@891 69
        mv "$CONFIG_DIR/config.sh" "$CONFIG_DIR/config.sh.backup"
paul@891 70
    fi
paul@891 71
fi
paul@891 72
paul@671 73
# Replace the config module with a symbolic link.
paul@671 74
paul@671 75
mv "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/"
paul@671 76
ln -s "$CONFIG_DIR/config.py" "$INSTALL_DIR/imiptools/config.py"
paul@102 77
paul@891 78
# Copy the config script.
paul@891 79
paul@891 80
cp tools/config.sh "$CONFIG_DIR/"
paul@891 81
paul@670 82
# Tools
paul@670 83
paul@1036 84
TOOLS="fix.sh init.sh init_user.sh make_freebusy.py update_scheduling_modules.py"
paul@752 85
paul@670 86
if [ ! -e "$INSTALL_DIR/tools" ]; then
paul@670 87
    mkdir -p "$INSTALL_DIR/tools"
paul@670 88
fi
paul@670 89
paul@752 90
for TOOL in $TOOLS; do
paul@752 91
    cp "tools/$TOOL" "$INSTALL_DIR/tools/"
paul@752 92
done
paul@670 93
paul@670 94
# Web manager interface.
paul@670 95
paul@102 96
if [ ! -e "$WEB_INSTALL_DIR" ]; then
paul@102 97
    mkdir -p "$WEB_INSTALL_DIR"
paul@102 98
fi
paul@102 99
paul@102 100
cp imip_manager.py "$WEB_INSTALL_DIR"
paul@188 101
cp htdocs/styles.css "$WEB_INSTALL_DIR"
paul@440 102
paul@440 103
if [ ! -e "$WEB_INSTALL_DIR/imipweb" ]; then
paul@668 104
    mkdir "$WEB_INSTALL_DIR/imipweb"
paul@440 105
fi
paul@440 106
paul@668 107
cp imipweb/*.py "$WEB_INSTALL_DIR/imipweb/"
paul@1008 108
paul@1008 109
# Locale directory.
paul@1008 110
paul@1008 111
if [ ! "$NO_LOCALE_DIR" ] && [ -e "locale" ]; then
paul@1008 112
    for DIR in "locale/"*"/LC_MESSAGES" ; do
paul@1008 113
        mkdir -p "$INSTALL_DIR/$DIR"
paul@1008 114
        cp "$DIR/"*.mo "$INSTALL_DIR/$DIR/"
paul@1008 115
    done
paul@1008 116
fi
paul@1036 117
paul@1036 118
# Run the scheduling module update tool to regenerate the manifest module.
paul@1036 119
paul@1036 120
PYTHONPATH="$INSTALL_DIR" "$INSTALL_DIR/tools/update_scheduling_modules.py"