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@1216 | 47 | # Package modules. |
paul@1216 | 48 | |
paul@1028 | 49 | for DIR in "$INSTALL_DIR/imiptools" \ |
paul@1069 | 50 | "$INSTALL_DIR/imiptools/stores" \ |
paul@1088 | 51 | "$INSTALL_DIR/imiptools/stores/database" \ |
paul@1028 | 52 | "$INSTALL_DIR/imiptools/handlers" \ |
paul@1028 | 53 | "$INSTALL_DIR/imiptools/handlers/scheduling" ; do |
paul@1028 | 54 | if [ ! -e "$DIR" ]; then |
paul@1028 | 55 | mkdir "$DIR" |
paul@1028 | 56 | fi |
paul@1028 | 57 | done |
paul@440 | 58 | |
paul@1216 | 59 | # Remove any symbolic link to the config module. This linking is no longer |
paul@1216 | 60 | # supported, anyway. |
paul@671 | 61 | |
paul@671 | 62 | if [ -h "$INSTALL_DIR/imiptools/config.py" ]; then |
paul@671 | 63 | rm "$INSTALL_DIR/imiptools/config.py" |
paul@671 | 64 | fi |
paul@671 | 65 | |
paul@671 | 66 | # Copy modules into the installation directory. |
paul@671 | 67 | |
paul@671 | 68 | cp imiptools/*.py "$INSTALL_DIR/imiptools/" |
paul@1069 | 69 | cp imiptools/stores/*.py "$INSTALL_DIR/imiptools/stores/" |
paul@1088 | 70 | cp imiptools/stores/database/*.py "$INSTALL_DIR/imiptools/stores/database/" |
paul@671 | 71 | cp imiptools/handlers/*.py "$INSTALL_DIR/imiptools/handlers/" |
paul@1028 | 72 | cp imiptools/handlers/scheduling/*.py "$INSTALL_DIR/imiptools/handlers/scheduling/" |
paul@1028 | 73 | |
paul@1028 | 74 | # Remove migrated modules. |
paul@1028 | 75 | |
paul@1028 | 76 | if [ -e "$INSTALL_DIR/imiptools/handlers/scheduling.py" ]; then |
paul@1028 | 77 | rm "$INSTALL_DIR/imiptools/handlers/scheduling.py"* |
paul@1028 | 78 | fi |
paul@671 | 79 | |
paul@1069 | 80 | if [ -e "$INSTALL_DIR/imip_store.py" ]; then |
paul@1069 | 81 | rm "$INSTALL_DIR/imip_store.py"* |
paul@1069 | 82 | fi |
paul@1069 | 83 | |
paul@1210 | 84 | # Install the configuration in a more appropriate location. |
paul@1129 | 85 | # Create new versions of configuration files instead of overwriting. |
paul@671 | 86 | |
paul@671 | 87 | if [ ! -e "$CONFIG_DIR" ]; then |
paul@671 | 88 | mkdir -p "$CONFIG_DIR" |
paul@671 | 89 | fi |
paul@671 | 90 | |
paul@1210 | 91 | # Handle any old config module in the configuration location. |
paul@1210 | 92 | |
paul@671 | 93 | if [ -e "$CONFIG_DIR/config.py" ]; then |
paul@1210 | 94 | |
paul@1210 | 95 | # Rename the old config module. |
paul@1210 | 96 | |
paul@1210 | 97 | mv "$CONFIG_DIR/config.py" "$CONFIG_DIR/config.txt" |
paul@1210 | 98 | fi |
paul@1210 | 99 | |
paul@1210 | 100 | # Handle any existing configuration file in the configuration location. |
paul@1210 | 101 | |
paul@1210 | 102 | if [ -e "$CONFIG_DIR/config.txt" ]; then |
paul@1210 | 103 | |
paul@1210 | 104 | # Install the new configuration file alongside the existing file if |
paul@1210 | 105 | # different. |
paul@1210 | 106 | |
paul@1211 | 107 | if ! cmp "imiptools/config.txt" "$CONFIG_DIR/config.txt" > /dev/null 2>&1 ; then |
paul@1211 | 108 | cp "imiptools/config.txt" "$CONFIG_DIR/config.txt.new" |
paul@1131 | 109 | fi |
paul@1210 | 110 | |
paul@1210 | 111 | # Otherwise, just copy the configuration file. |
paul@1210 | 112 | |
paul@1129 | 113 | else |
paul@1211 | 114 | cp "imiptools/config.txt" "$CONFIG_DIR/config.txt" |
paul@668 | 115 | fi |
paul@668 | 116 | |
paul@1210 | 117 | # Update the tools configuration file. |
paul@1210 | 118 | |
paul@891 | 119 | if [ -e "$CONFIG_DIR/config.sh" ]; then |
paul@1131 | 120 | if ! cmp "tools/config.sh" "$CONFIG_DIR/config.sh" > /dev/null 2>&1 ; then |
paul@1131 | 121 | cp "tools/config.sh" "$CONFIG_DIR/config.sh.new" |
paul@1131 | 122 | fi |
paul@1129 | 123 | else |
paul@1129 | 124 | cp "tools/config.sh" "$CONFIG_DIR/config.sh" |
paul@891 | 125 | fi |
paul@891 | 126 | |
paul@1096 | 127 | # Copy related configuration files. |
paul@1096 | 128 | |
paul@1096 | 129 | if [ ! -e "$CONFIG_DIR/postgresql" ]; then |
paul@1096 | 130 | mkdir -p "$CONFIG_DIR/postgresql" |
paul@1096 | 131 | fi |
paul@1096 | 132 | |
paul@1130 | 133 | if [ -e "$CONFIG_DIR/postgresql/schema.sql" ]; then |
paul@1132 | 134 | if ! cmp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" > /dev/null 2>&1 ; then |
paul@1132 | 135 | cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql.new" |
paul@1132 | 136 | fi |
paul@1130 | 137 | else |
paul@1130 | 138 | cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" |
paul@1130 | 139 | fi |
paul@1096 | 140 | |
paul@670 | 141 | # Tools |
paul@670 | 142 | |
paul@1202 | 143 | TOOLS="copy_store.py fix.sh init.sh init_user.sh make_freebusy.py set_delegates.py "\ |
paul@1216 | 144 | "set_quota_groups.py set_quota_limits.py update_quotas.py" |
paul@1216 | 145 | |
paul@1216 | 146 | OLD_TOOLS="update_scheduling_modules.py update_storage_modules.py" |
paul@752 | 147 | |
paul@670 | 148 | if [ ! -e "$INSTALL_DIR/tools" ]; then |
paul@670 | 149 | mkdir -p "$INSTALL_DIR/tools" |
paul@670 | 150 | fi |
paul@670 | 151 | |
paul@752 | 152 | for TOOL in $TOOLS; do |
paul@752 | 153 | cp "tools/$TOOL" "$INSTALL_DIR/tools/" |
paul@752 | 154 | done |
paul@670 | 155 | |
paul@1216 | 156 | for TOOL in $OLD_TOOLS; do |
paul@1216 | 157 | if [ -e "$INSTALL_DIR/tools/$TOOL" ]; then |
paul@1216 | 158 | rm "$INSTALL_DIR/tools/$TOOL" |
paul@1216 | 159 | fi |
paul@1216 | 160 | done |
paul@1216 | 161 | |
paul@670 | 162 | # Web manager interface. |
paul@670 | 163 | |
paul@102 | 164 | if [ ! -e "$WEB_INSTALL_DIR" ]; then |
paul@102 | 165 | mkdir -p "$WEB_INSTALL_DIR" |
paul@102 | 166 | fi |
paul@102 | 167 | |
paul@102 | 168 | cp imip_manager.py "$WEB_INSTALL_DIR" |
paul@188 | 169 | cp htdocs/styles.css "$WEB_INSTALL_DIR" |
paul@440 | 170 | |
paul@440 | 171 | if [ ! -e "$WEB_INSTALL_DIR/imipweb" ]; then |
paul@668 | 172 | mkdir "$WEB_INSTALL_DIR/imipweb" |
paul@440 | 173 | fi |
paul@440 | 174 | |
paul@668 | 175 | cp imipweb/*.py "$WEB_INSTALL_DIR/imipweb/" |
paul@1008 | 176 | |
paul@1008 | 177 | # Locale directory. |
paul@1008 | 178 | |
paul@1158 | 179 | if [ ! "$NO_LOCALE_DIR" ]; then |
paul@1158 | 180 | |
paul@1158 | 181 | # Make the locale directory if it does not exist. |
paul@1158 | 182 | |
paul@1158 | 183 | if [ ! -e "locale" ]; then |
paul@1158 | 184 | "tools/i18n_format.sh" |
paul@1158 | 185 | fi |
paul@1158 | 186 | |
paul@1158 | 187 | # Only copy the translations if they do now exist. |
paul@1158 | 188 | |
paul@1158 | 189 | if [ -e "locale" ]; then |
paul@1158 | 190 | for DIR in "locale/"*"/LC_MESSAGES" ; do |
paul@1158 | 191 | mkdir -p "$INSTALL_DIR/$DIR" |
paul@1158 | 192 | cp "$DIR/"*.mo "$INSTALL_DIR/$DIR/" |
paul@1158 | 193 | done |
paul@1158 | 194 | fi |
paul@1008 | 195 | fi |