upgrade_roundcube.sh: some fixes..

This commit is contained in:
2026-07-03 17:08:56 +02:00
parent 5b9e632fe4
commit d60cb62d8f
+163 -1
View File
@@ -968,6 +968,70 @@ export COMPOSER_ALLOW_SUPERUSER=1
export COMPOSER_ROOT_VERSION=${ROUNDCUBE_VERSION} export COMPOSER_ROOT_VERSION=${ROUNDCUBE_VERSION}
echononl " Deactivate spellcheck_engine (pspell not available in PHP 8.4+).."
if grep -q "spellcheck_engine.*pspell" "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php" 2>/dev/null ; then
sed -i "s/\\\$config\['spellcheck_engine'\].*=.*'pspell'.*/\$config['spellcheck_engine'] = '';/" \
"${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
echononl " Replace deprecated markasjunk2 plugin with built-in markasjunk.."
if grep -q "'markasjunk2'" "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php" 2>/dev/null ; then
sed -i "s/'markasjunk2'/'markasjunk'/" \
"${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
echononl " Copy composer.json from source archive to installation directory.."
cp "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}/composer.json" \
"${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/composer.json" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
echononl " Remove old composer.lock (force fresh dependency resolution).."
if [[ -f "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/composer.lock" ]]; then
rm "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/composer.lock" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
echononl " Allow Plugins .." echononl " Allow Plugins .."
php composer.phar --no-interaction config allow-plugins.roundcube/plugin-installer true > $log_file 2>&1 php composer.phar --no-interaction config allow-plugins.roundcube/plugin-installer true > $log_file 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@@ -1044,6 +1108,105 @@ else
fi fi
echononl " Regenerate Composer autoloader (remove stale files).."
_autoload_dir="${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/vendor/composer"
rm -f "${_autoload_dir}/autoload_real.php" \
"${_autoload_dir}/ClassLoader.php" \
"${_autoload_dir}/InstalledVersions.php" \
"${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/vendor/autoload.php"
php composer.phar --no-interaction dump-autoload > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
echononl " Run database schema migration (bin/updatedb.sh).."
php ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/updatedb.sh \
--package=roundcube \
--dir=${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/SQL \
> $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
# Check if failure is due to a partially applied migration ("already exists")
if grep -q "already exists\|existiert bereits" $log_file ; then
warn "DB migration had 'already exists' errors - attempting to skip failed migration and retry.."
# Extract the failed migration ID from the error output
_failed_migration=$(grep -oE "\([0-9]{10}\)" $log_file | head -1 | tr -d '()')
if [[ -n "$_failed_migration" ]]; then
info "Setting DB schema version to '${_failed_migration}' and retrying.."
if [[ "$DB_TYPE" = "pgsql" ]]; then
su - postgres -c "${psql_command} -q -d ${DB_NAME} -c \
\"UPDATE system SET value='${_failed_migration}' WHERE name='roundcube-version';\"" > $log_file 2>&1
elif [[ "$DB_TYPE" = "mysql" ]]; then
${mysql_command} ${MYSQL_CREDENTIALS} ${DB_NAME} -e \
"UPDATE system SET value='${_failed_migration}' WHERE name='roundcube-version';" > $log_file 2>&1
fi
# Retry migration
php ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/updatedb.sh \
--package=roundcube \
--dir=${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/SQL \
>> $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "Retry also failed:\n$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
else
echo_failed
error "Could not extract failed migration ID.\ncommand was:\n\t# php ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/updatedb.sh --package=roundcube --dir=${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/SQL\n\n$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
else
echo_failed
error "command was:\n\t# php ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/updatedb.sh --package=roundcube --dir=${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/SQL\n\n$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
fi
echononl " Index build-in addressbook" echononl " Index build-in addressbook"
${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/indexcontacts.sh > $log_file 2>&1 ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/indexcontacts.sh > $log_file 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@@ -1180,4 +1343,3 @@ fi
echo "" echo ""
clean_up 0 clean_up 0