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 config module 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 if [ -e "$CONFIG_DIR/config.py" ]; then 89 if ! cmp "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py" > /dev/null 2>&1 ; then 90 mv "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py.new" 91 fi 92 else 93 mv "$INSTALL_DIR/imiptools/config.py" "$CONFIG_DIR/config.py" 94 fi 95 96 if [ -e "$CONFIG_DIR/config.sh" ]; then 97 if ! cmp "tools/config.sh" "$CONFIG_DIR/config.sh" > /dev/null 2>&1 ; then 98 cp "tools/config.sh" "$CONFIG_DIR/config.sh.new" 99 fi 100 else 101 cp "tools/config.sh" "$CONFIG_DIR/config.sh" 102 fi 103 104 # Replace the config module with a symbolic link. 105 106 ln -s "$CONFIG_DIR/config.py" "$INSTALL_DIR/imiptools/config.py" 107 108 # Copy related configuration files. 109 110 if [ ! -e "$CONFIG_DIR/postgresql" ]; then 111 mkdir -p "$CONFIG_DIR/postgresql" 112 fi 113 114 if [ -e "$CONFIG_DIR/postgresql/schema.sql" ]; then 115 if ! cmp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" > /dev/null 2>&1 ; then 116 cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql.new" 117 fi 118 else 119 cp "conf/postgresql/schema.sql" "$CONFIG_DIR/postgresql/schema.sql" 120 fi 121 122 # Tools 123 124 TOOLS="copy_store.py fix.sh init.sh init_user.sh make_freebusy.py set_delegates.py "\ 125 "set_quota_groups.py set_quota_limits.py update_quotas.py update_scheduling_modules.py "\ 126 "update_storage_modules.py" 127 128 if [ ! -e "$INSTALL_DIR/tools" ]; then 129 mkdir -p "$INSTALL_DIR/tools" 130 fi 131 132 for TOOL in $TOOLS; do 133 cp "tools/$TOOL" "$INSTALL_DIR/tools/" 134 done 135 136 # Web manager interface. 137 138 if [ ! -e "$WEB_INSTALL_DIR" ]; then 139 mkdir -p "$WEB_INSTALL_DIR" 140 fi 141 142 cp imip_manager.py "$WEB_INSTALL_DIR" 143 cp htdocs/styles.css "$WEB_INSTALL_DIR" 144 145 if [ ! -e "$WEB_INSTALL_DIR/imipweb" ]; then 146 mkdir "$WEB_INSTALL_DIR/imipweb" 147 fi 148 149 cp imipweb/*.py "$WEB_INSTALL_DIR/imipweb/" 150 151 # Locale directory. 152 153 if [ ! "$NO_LOCALE_DIR" ]; then 154 155 # Make the locale directory if it does not exist. 156 157 if [ ! -e "locale" ]; then 158 "tools/i18n_format.sh" 159 fi 160 161 # Only copy the translations if they do now exist. 162 163 if [ -e "locale" ]; then 164 for DIR in "locale/"*"/LC_MESSAGES" ; do 165 mkdir -p "$INSTALL_DIR/$DIR" 166 cp "$DIR/"*.mo "$INSTALL_DIR/$DIR/" 167 done 168 fi 169 fi 170 171 # Run the scheduling module update tool to regenerate the manifest module. 172 173 PYTHONPATH="$INSTALL_DIR" "$INSTALL_DIR/tools/update_scheduling_modules.py" 174 175 # Run the storage module update tool to regenerate the manifest module. 176 177 PYTHONPATH="$INSTALL_DIR" "$INSTALL_DIR/tools/update_storage_modules.py"