imip-agent

tools/install.sh

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