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