paul@102 | 1 | #!/bin/sh |
paul@102 | 2 | |
paul@1201 | 3 | # This tool installs the imip-agent software and message resources. It is |
paul@1201 | 4 | # configured by the contents of the config.sh script. |
paul@1201 | 5 | # |
paul@1206 | 6 | # Copyright (C) 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk> |
paul@1201 | 7 | # |
paul@1201 | 8 | # This program is free software; you can redistribute it and/or modify it under |
paul@1201 | 9 | # the terms of the GNU General Public License as published by the Free Software |
paul@1201 | 10 | # Foundation; either version 3 of the License, or (at your option) any later |
paul@1201 | 11 | # version. |
paul@1201 | 12 | # |
paul@1201 | 13 | # This program is distributed in the hope that it will be useful, but WITHOUT |
paul@1201 | 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@1201 | 15 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@1201 | 16 | # details. |
paul@1201 | 17 | # |
paul@1201 | 18 | # You should have received a copy of the GNU General Public License along with |
paul@1201 | 19 | # this program. If not, see <http://www.gnu.org/licenses/>. |
paul@1201 | 20 | |
paul@1108 | 21 | DIRNAME=`dirname "$0"` |
paul@954 | 22 | |
paul@954 | 23 | if [ -e "$DIRNAME/config.sh" ]; then |
paul@954 | 24 | . "$DIRNAME/config.sh" |
paul@954 | 25 | else |
paul@954 | 26 | . /etc/imip-agent/config.sh |
paul@954 | 27 | fi |
paul@954 | 28 | |
paul@1008 | 29 | if [ "$1" = "--no-locale-dir" ]; then |
paul@1008 | 30 | NO_LOCALE_DIR=$1 |
paul@1008 | 31 | else |
paul@1008 | 32 | NO_LOCALE_DIR= |
paul@1008 | 33 | fi |
paul@1008 | 34 | |
paul@670 | 35 | # Agents and modules. |
paul@670 | 36 | |
paul@102 | 37 | AGENTS="imip_person.py imip_person_outgoing.py imip_resource.py" |
paul@1069 | 38 | MODULES="markup.py vCalendar.py vContent.py vRecurrence.py" |
paul@102 | 39 | |
paul@102 | 40 | if [ ! -e "$INSTALL_DIR" ]; then |
paul@102 | 41 | mkdir -p "$INSTALL_DIR" |
paul@102 | 42 | fi |
paul@102 | 43 | |
paul@102 | 44 | cp $AGENTS "$INSTALL_DIR" |
paul@102 | 45 | cp $MODULES "$INSTALL_DIR" |
paul@440 | 46 | |
paul@1028 | 47 | for DIR in "$INSTALL_DIR/imiptools" \ |
paul@1069 | 48 | "$INSTALL_DIR/imiptools/stores" \ |
paul@1088 | 49 | "$INSTALL_DIR/imiptools/stores/database" \ |
paul@1028 | 50 | "$INSTALL_DIR/imiptools/handlers" \ |
paul@1028 | 51 | "$INSTALL_DIR/imiptools/handlers/scheduling" ; do |
paul@1028 | 52 | if [ ! -e "$DIR" ]; then |
paul@1028 | 53 | mkdir "$DIR" |
paul@1028 | 54 | fi |
paul@1028 | 55 | done |
paul@440 | 56 | |
paul@671 | 57 | # Remove any symbolic link to the config module. |
paul@671 | 58 | |
paul@671 | 59 | if [ -h "$INSTALL_DIR/imiptools/config.py" ]; then |
paul@671 | 60 | rm "$INSTALL_DIR/imiptools/config.py" |
paul@671 | 61 | fi |
paul@671 | 62 | |
paul@671 | 63 | # Copy modules into the installation directory. |
paul@671 | 64 | |
paul@671 | 65 | cp imiptools/*.py "$INSTALL_DIR/imiptools/" |
paul@1069 | 66 | cp imiptools/stores/*.py "$INSTALL_DIR/imiptools/stores/" |
paul@1088 | 67 | cp imiptools/stores/database/*.py "$INSTALL_DIR/imiptools/stores/database/" |
paul@671 | 68 | cp imiptools/handlers/*.py "$INSTALL_DIR/imiptools/handlers/" |
paul@1028 | 69 | cp imiptools/handlers/scheduling/*.py "$INSTALL_DIR/imiptools/handlers/scheduling/" |
paul@1028 | 70 | |
paul@1028 | 71 | # Remove migrated modules. |
paul@1028 | 72 | |
paul@1028 | 73 | if [ -e "$INSTALL_DIR/imiptools/handlers/scheduling.py" ]; then |
paul@1028 | 74 | rm "$INSTALL_DIR/imiptools/handlers/scheduling.py"* |
paul@1028 | 75 | fi |
paul@671 | 76 | |
paul@1069 | 77 | if [ -e "$INSTALL_DIR/imip_store.py" ]; then |
paul@1069 | 78 | rm "$INSTALL_DIR/imip_store.py"* |
paul@1069 | 79 | fi |
paul@1069 | 80 | |
paul@671 | 81 | # Install the config module in a more appropriate location. |
paul@1129 | 82 | # Create new versions of configuration files instead of overwriting. |
paul@671 | 83 | |
paul@671 | 84 | if [ ! -e "$CONFIG_DIR" ]; then |
paul@671 | 85 | mkdir -p "$CONFIG_DIR" |
paul@671 | 86 | fi |
paul@671 | 87 | |
paul@671 | 88 | if [ -e "$CONFIG_DIR/config.py" ]; then |
paul@1131 | 89 | if ! cmp "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py" > /dev/null 2>&1 ; then |
paul@1131 | 90 | mv "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py.new" |
paul@1131 | 91 | fi |
paul@1129 | 92 | else |
paul@1129 | 93 | mv "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py" |
paul@668 | 94 | fi |
paul@668 | 95 | |
paul@891 | 96 | if [ -e "$CONFIG_DIR/config.sh" ]; then |
paul@1131 | 97 | if ! cmp "tools/config.sh" "$CONFIG_DIR/config.sh" > /dev/null 2>&1 ; then |
paul@1131 | 98 | cp "tools/config.sh" "$CONFIG_DIR/config.sh.new" |
paul@1131 | 99 | fi |
paul@1129 | 100 | else |
paul@1129 | 101 | cp "tools/config.sh" "$CONFIG_DIR/config.sh" |
paul@891 | 102 | fi |
paul@891 | 103 | |
paul@671 | 104 | # Replace the config module with a symbolic link. |
paul@671 | 105 | |
paul@671 | 106 | ln -s "$CONFIG_DIR/config.py" "$INSTALL_DIR/imiptools/config.py" |
paul@102 | 107 | |
paul@1096 | 108 | # Copy related configuration files. |
paul@1096 | 109 | |
paul@1096 | 110 | if [ ! -e "$CONFIG_DIR/postgresql" ]; then |
paul@1096 | 111 | mkdir -p "$CONFIG_DIR/postgresql" |
paul@1096 | 112 | fi |
paul@1096 | 113 | |
paul@1130 | 114 | if [ -e "$CONFIG_DIR/postgresql/schema.sql" ]; then |
paul@1132 | 115 | if ! cmp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" > /dev/null 2>&1 ; then |
paul@1132 | 116 | cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql.new" |
paul@1132 | 117 | fi |
paul@1130 | 118 | else |
paul@1130 | 119 | cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" |
paul@1130 | 120 | fi |
paul@1096 | 121 | |
paul@670 | 122 | # Tools |
paul@670 | 123 | |
paul@1202 | 124 | TOOLS="copy_store.py fix.sh init.sh init_user.sh make_freebusy.py set_delegates.py "\ |
paul@1206 | 125 | "set_quota_groups.py set_quota_limits.py update_quotas.py update_scheduling_modules.py "\ |
paul@1206 | 126 | "update_storage_modules.py" |
paul@752 | 127 | |
paul@670 | 128 | if [ ! -e "$INSTALL_DIR/tools" ]; then |
paul@670 | 129 | mkdir -p "$INSTALL_DIR/tools" |
paul@670 | 130 | fi |
paul@670 | 131 | |
paul@752 | 132 | for TOOL in $TOOLS; do |
paul@752 | 133 | cp "tools/$TOOL" "$INSTALL_DIR/tools/" |
paul@752 | 134 | done |
paul@670 | 135 | |
paul@670 | 136 | # Web manager interface. |
paul@670 | 137 | |
paul@102 | 138 | if [ ! -e "$WEB_INSTALL_DIR" ]; then |
paul@102 | 139 | mkdir -p "$WEB_INSTALL_DIR" |
paul@102 | 140 | fi |
paul@102 | 141 | |
paul@102 | 142 | cp imip_manager.py "$WEB_INSTALL_DIR" |
paul@188 | 143 | cp htdocs/styles.css "$WEB_INSTALL_DIR" |
paul@440 | 144 | |
paul@440 | 145 | if [ ! -e "$WEB_INSTALL_DIR/imipweb" ]; then |
paul@668 | 146 | mkdir "$WEB_INSTALL_DIR/imipweb" |
paul@440 | 147 | fi |
paul@440 | 148 | |
paul@668 | 149 | cp imipweb/*.py "$WEB_INSTALL_DIR/imipweb/" |
paul@1008 | 150 | |
paul@1008 | 151 | # Locale directory. |
paul@1008 | 152 | |
paul@1158 | 153 | if [ ! "$NO_LOCALE_DIR" ]; then |
paul@1158 | 154 | |
paul@1158 | 155 | # Make the locale directory if it does not exist. |
paul@1158 | 156 | |
paul@1158 | 157 | if [ ! -e "locale" ]; then |
paul@1158 | 158 | "tools/i18n_format.sh" |
paul@1158 | 159 | fi |
paul@1158 | 160 | |
paul@1158 | 161 | # Only copy the translations if they do now exist. |
paul@1158 | 162 | |
paul@1158 | 163 | if [ -e "locale" ]; then |
paul@1158 | 164 | for DIR in "locale/"*"/LC_MESSAGES" ; do |
paul@1158 | 165 | mkdir -p "$INSTALL_DIR/$DIR" |
paul@1158 | 166 | cp "$DIR/"*.mo "$INSTALL_DIR/$DIR/" |
paul@1158 | 167 | done |
paul@1158 | 168 | fi |
paul@1008 | 169 | fi |
paul@1036 | 170 | |
paul@1036 | 171 | # Run the scheduling module update tool to regenerate the manifest module. |
paul@1036 | 172 | |
paul@1036 | 173 | PYTHONPATH="$INSTALL_DIR" "$INSTALL_DIR/tools/update_scheduling_modules.py" |
paul@1206 | 174 | |
paul@1206 | 175 | # Run the storage module update tool to regenerate the manifest module. |
paul@1206 | 176 | |
paul@1206 | 177 | PYTHONPATH="$INSTALL_DIR" "$INSTALL_DIR/tools/update_storage_modules.py" |