#!/usr/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/roundcube-check-database - check Roundcube database layout # # Copyright (c) 2012-2025 The Eisfair Team, team(at)eisfair(dot)org # # Creation : 2013-01-08 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------ # read eislib . /var/install/include/eislib #exec 2>/tmp/roundcube-db-check-trace-$$.log #set -x DB_NAME='roundcubemail' configfile=/etc/config.d/roundcube if [ -s ${configfile} ] then . ${configfile} if [ "${START_ROUNDCUBE}" = 'yes' ] then idx=1 while [ ${idx} -le ${ROUNDCUBE_N} ] do eval active='$ROUNDCUBE_'${idx}'_ACTIVE' if [ "${active}" = 'yes' ] then eval docroot='$ROUNDCUBE_'${idx}'_DOCUMENT_ROOT' break fi idx=`expr ${idx} + 1` done # set default database type if [ -z "${ROUNDCUBE_DB_TYPE}" ] then ROUNDCUBE_DB_TYPE='sqlite' fi updatefile=${docroot}/bin/update.sh if [ -f ${updatefile} ] then # set execution right chmod 0544 ${updatefile} clrhome mecho --info "Check Roundcube '${ROUNDCUBE_DB_TYPE}' database layout" echo echo "executing '${updatefile} ..." echo db_version=`/var/install/config.d/roundcube.sh --show-version 'db'` rc_version=`/var/install/config.d/roundcube.sh --show-version 'rc'` if [ "${db_version}" != "${rc_version}" ] then # run db check echo "${ROUNDCUBE_DB_TYPE}-version : ${db_version}" echo "roundcube-version: ${rc_version}" echo answer_file=/tmp/roundcube-check-database.$$ echo -e '?' > ${answer_file} output=`${updatefile} < ${answer_file}` rm -f ${answer_file} if [ -n "${output}" ] then echo "${output}" | grep -q 'This instance of Roundcube is up-to-date' if [ $? -ne 0 ] then echo '-------------------------------------------------------------------' echo "${output}" echo '-------------------------------------------------------------------' echo "Done." echo mecho --warn "If '[FAILED]' is shown for one of the listed steps you need to check" mecho --warn 'the commands in question manually and repeat this check until no' mecho --warn 'further errors are shown!' echo echo 'To manually check the sql command to be executed, open the relevant sql file,' echo "e.g. './SQL/${ROUNDCUBE_DB_TYPE}/2013061000.sql' which contains the commands:" echo echo 'ALTER TABLE `cache` ADD `expires` datetime DEFAULT NULL;' echo 'ALTER TABLE `cache_shared` ADD `expires` datetime DEFAULT NULL;' echo 'ALTER TABLE `cache_index` ADD `expires` datetime DEFAULT NULL;' echo '...' echo echo 'Next you open the SQL console, select the database and check the table, e.g:' echo case ${ROUNDCUBE_DB_TYPE} in mysql ) echo 'mysql -Droundcubemail # connect to database' echo 'show tables; # show available tables' echo 'describe cache; # show table structure' echo 'quit # quit program' ;; pgsql ) echo 'psql roundcubemail # connect to database' echo '\dt # show available tables' echo '\d cache # show table structure' echo '\q # quit program' ;; sqlite ) echo 'sqlite3 ./roundcubemail.db # connect to database' echo '.tables # show available tables' echo '.schema cache # show table structure' echo '.quit # quit program' ;; esac echo echo "If the table already exists the mentioned column 'expires', you can comment" echo "The first sql command line by prefixing it with '-- ' and rerun this check." else mecho --info "The database is up-to-date!" fi fi # remove execution right chmod 0444 ${updatefile} else mecho --info "The database is up-to-date!" fi else mecho --error "The script '${updatefile}' doesn't exist!" fi else mecho --error "START_ROUNTCUBE='yes' need to be set to use this function!" fi else mecho --error "The configuration file '${configfile}' doesn't exist!" fi echo anykey exit 0