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