1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00
roundcube_ynh/scripts/upgrade

212 lines
7.9 KiB
Text
Raw Normal View History

#!/bin/bash
2017-08-26 03:24:41 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-06-02 17:15:57 +02:00
source _common.sh
source /usr/share/yunohost/helpers
2019-05-18 18:42:54 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
2017-08-26 03:24:41 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2021-08-18 21:46:27 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2019-03-03 18:12:41 +01:00
# If with_carddav doesn't exist, create it
2023-05-03 16:25:14 +02:00
if [ -z "${with_carddav:-}" ]; then
2023-05-03 16:16:05 +02:00
if [ -f "$install_dir/plugins/carddav/config.inc.php" ]
2019-03-03 18:12:41 +01:00
then
with_carddav=1
else
with_carddav=0
fi
2019-05-18 18:42:54 +02:00
ynh_app_setting_set --app=$app --key=with_carddav --value=$with_carddav
2019-03-03 18:12:41 +01:00
fi
# If language doesn't exist, create it
2023-05-03 16:25:14 +02:00
if [ -z "${language:-}" ]; then
2020-11-20 22:06:07 +01:00
language="en_GB"
ynh_app_setting_set --app=$app --key=language --value=$language
fi
2020-11-20 22:06:07 +01:00
# If fpm_footprint doesn't exist, create it
2023-05-03 16:25:14 +02:00
if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
Testing (#159) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README * Upgrade config panel (#158) * fix pgp home path in a muti-install context * Update manifest.json * config panel * fix * Update install * Update upgrade * Fix pgp home path in a muti-install context (#157) * fix pgp home path in a muti-install context * Update manifest.json * Update _common.sh Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-09-30 18:31:12 +02:00
# If fpm_free_footprint doesn't exist, create it
2023-05-03 16:25:14 +02:00
if [ -z "${fpm_free_footprint:-}" ]; then
Testing (#159) * Update config.inc.php (#122) * Update manifest.json * Auto-update README * 1.5.1 (#124) * 1.5.1 * Add config panel (#128) * Plugin upgrade (#127) * Update plugins * Update config.inc.php * Update manifest.json * Auto-update README * Update remove * Update check_process * Update upgrade * 1.5.2 (#131) * 1.5.2 * Update config.inc.php (#134) * Fix plugins urls (#137) * fix plugins urls sblaisot/automatic_addressbook is abandonned and forked at projectmyst/automatic_addressbook * fix plugins urls as in previous commit * fix html5 plugin url * fix html5 plugin url * Auto-update README * Auto-update README * 1.5.3 (#142) * 1.5.3 * Auto-update README Co-authored-by: yunohost-bot <yunohost@yunohost.org> * user * Update _common.sh * Update _common.sh * version 16 (#146) * Fix * Auto-update README * Update config.inc.php * Update config.inc.php * Update install * Update install * Update install * Update install * Update upgrade * PHP8.0 * Update app.src * Update restore Co-authored-by: Yunohost-Bot <> * bullseye (#149) * bullseye * Auto-update README * Update app.src * set max filesize * Fix Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * PHP7.4 * Update upgrade * Update _common.sh * Update upgrade * Install JS dependencies (#154) * INSTALL JS DEPENDENCIES * Update install * Update manifest.json * Auto-update README * Upgrade config panel (#158) * fix pgp home path in a muti-install context * Update manifest.json * config panel * fix * Update install * Update upgrade * Fix pgp home path in a muti-install context (#157) * fix pgp home path in a muti-install context * Update manifest.json * Update _common.sh Co-authored-by: Yunohost-Bot <> Co-authored-by: Xavier Brochard <xavier@alternatif.org> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: SuNounix <91945628+SuNounix@users.noreply.github.com>
2022-09-30 18:31:12 +02:00
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
# If fpm_usage doesn't exist, create it
2023-05-03 16:25:14 +02:00
if [ -z "${fpm_usage:-}" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
2017-08-26 03:24:41 +02:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Get the current version of roundcube
2023-05-03 16:16:05 +02:00
oldversion=$(grep RCMAIL_VERSION "$install_dir/program/include/iniset.php" | cut -d\' -f4)
2017-08-26 03:24:41 +02:00
2019-05-18 18:42:54 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=3
# Download, check integrity, uncompress and patch the source from app.src
2023-05-03 16:16:05 +02:00
ynh_setup_source --dest_dir="$install_dir"
2019-05-18 18:42:54 +02:00
fi
2017-08-26 03:24:41 +02:00
2023-05-03 16:16:05 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-10-19 12:45:44 +02:00
2017-08-26 03:24:41 +02:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2020-09-27 22:39:12 +02:00
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=5
2020-09-27 22:39:12 +02:00
# Create a dedicated PHP-FPM config
2023-09-15 13:46:10 +02:00
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
# Create a dedicated NGINX config
ynh_add_nginx_config
2017-08-26 03:24:41 +02:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
2017-10-15 01:14:08 +02:00
# CONFIGURE ROUNDCUBE
2017-08-26 03:24:41 +02:00
#=================================================
2019-05-18 18:42:54 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
2019-03-03 18:12:41 +01:00
then
2021-08-18 21:46:27 +02:00
ynh_script_progression --message="Reconfiguring Roundcube..." --weight=1
2019-05-18 18:42:54 +02:00
2021-10-19 00:09:31 +02:00
deskey=$(ynh_string_random --length=24)
2023-05-03 16:16:05 +02:00
ynh_add_config --template="../conf/config.inc.php" --destination="$install_dir/config/config.inc.php"
2019-05-18 18:42:54 +02:00
#=================================================
# UPDATE DEPENDENCIES WITH COMPOSER
#=================================================
2023-05-03 16:25:14 +02:00
ynh_script_progression --message="Updating dependencies with Composer..." --weight=30
2019-05-18 18:42:54 +02:00
# Upgrade composer itself
ynh_install_composer
2020-09-27 22:39:12 +02:00
# Check if dependencies need to be updated with Composer
2023-05-03 16:16:05 +02:00
if [ -f "$install_dir/composer.json" ]
2019-05-18 18:42:54 +02:00
then
2021-10-19 12:45:44 +02:00
ynh_exec_warn_less ynh_composer_exec --commands="update"
# Update plugin-installer for Composer version 2.0
ynh_exec_warn_less ynh_composer_exec --commands="require roundcube/plugin-installer:>=0.2.0"
2019-05-18 18:42:54 +02:00
else
# Install composer.json
2023-05-03 16:16:05 +02:00
cp "$install_dir/composer.json-dist" "$install_dir/composer.json"
2019-05-18 18:42:54 +02:00
fi
2021-02-26 00:00:04 +01:00
2019-05-18 18:42:54 +02:00
#=================================================
# UPGRADE ADDITIONAL PLUGINS
#=================================================
ynh_script_progression --message="Upgrading additional plugins..." --weight=30
# Create logs and temp directories
2023-05-03 16:16:05 +02:00
mkdir -p "$install_dir/"{logs,temp}
2019-05-18 18:42:54 +02:00
2020-04-24 13:59:22 +02:00
# Install net_LDAP
2021-10-19 11:50:11 +02:00
ynh_composer_exec --commands="require kolab/net_ldap3"
2020-04-24 13:59:22 +02:00
2019-05-18 18:42:54 +02:00
# Update or install contextmenu and automatic_addressbook plugins
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
# https://plugins.roundcube.net/packages/johndoh/contextmenu
ynh_composer_exec --commands="update --no-dev --prefer-dist \
johndoh/contextmenu $contextmenu_version \
sblaisot/automatic_addressbook $automatic_addressbook_version"
2021-08-27 12:18:01 +02:00
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
2021-08-27 12:09:03 +02:00
2023-05-03 16:16:05 +02:00
ynh_add_config --template="../conf/enigma.config.inc.php" --destination="$install_dir/plugins/enigma/config.inc.php"
mkdir -p "$install_dir/plugins/enigma/home"
chown -R $app:$app "$install_dir/plugins/enigma/home"
2019-05-18 18:42:54 +02:00
# Update or install CardDAV plugin
if [ $with_carddav -eq 1 ]
then
ynh_composer_exec --commands="require roundcube/carddav $carddav_version --with-all-dependencies"
2019-05-18 18:42:54 +02:00
carddav_tmp_config="../conf/carddav.config.inc.php"
2020-04-24 13:34:42 +02:00
carddav_server=0
2019-05-18 18:42:54 +02:00
# Copy the plugin configuration file
2023-05-03 16:16:05 +02:00
cp $install_dir/plugins/carddav/config.inc.php{.dist,}
2019-05-18 18:42:54 +02:00
# Look for installed and supported CardDAV servers
2020-09-27 22:39:12 +02:00
for carddav_app in "nextcloud" "baikal"
2019-05-18 18:42:54 +02:00
do
carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
for carddav_app_id in $carddav_app_ids
do
2020-04-24 13:34:42 +02:00
carddav_server=1
# Append preset configuration to the config file
2023-05-03 16:16:05 +02:00
cat "../conf/${carddav_app}.inc.php" >> $install_dir/plugins/carddav/config.inc.php
2019-05-18 18:42:54 +02:00
# Retrieve app settings and enable relevant preset
2023-05-03 16:25:14 +02:00
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
2019-05-18 18:42:54 +02:00
carddav_url="https://${carddav_domain}${carddav_path%/}"
2023-05-03 16:16:05 +02:00
ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$install_dir/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$install_dir/plugins/carddav/config.inc.php"
done
2019-05-18 18:42:54 +02:00
done
# Do not actually add the carddav plugin if there's no carddav server available...
2020-04-24 13:34:42 +02:00
if [ $carddav_server -eq 1 ]
then
installed_plugins+=" 'carddav',"
fi
2019-05-18 18:42:54 +02:00
fi
#=================================================
# UPDATE ROUNDCUBE CONFIGURATION
#=================================================
2020-11-02 17:47:49 +01:00
ynh_script_progression --message="Updating $app configuration..." --weight=4
2019-05-18 18:42:54 +02:00
2023-05-03 16:16:05 +02:00
ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$install_dir/config/config.inc.php"
2019-05-18 18:42:54 +02:00
2020-09-27 22:39:12 +02:00
# Update JavaScript dependencies
2024-01-27 00:31:16 +01:00
pushd "$install_dir"
COMPOSER_ALLOW_SUPERUSER=1 "php$phpversion" ./bin/update.sh --version="?" -y <<< ""
2019-05-18 18:42:54 +02:00
2023-11-13 23:43:46 +01:00
# Store the config file checksum into the app settings
ynh_store_file_checksum --file="$install_dir/config/config.inc.php"
2023-11-13 23:43:46 +01:00
chmod 400 "$install_dir/config/config.inc.php"
chown $app:$app "$install_dir/config/config.inc.php"
2021-05-28 21:14:54 +02:00
2023-11-13 23:43:46 +01:00
#=================================================
# UPDATE ROUNDCUBE CORE
#=================================================
ynh_script_progression --message="Updating $app core..." --weight=4
2019-05-18 18:42:54 +02:00
COMPOSER_ALLOW_SUPERUSER=1 ynh_exec_warn "php$phpversion" ./bin/update.sh --version=$oldversion -y
popd
2017-07-03 15:05:22 +02:00
fi
2019-03-03 18:13:57 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-11-02 17:47:49 +01:00
ynh_script_progression --message="Installation of $app completed" --last