1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/framaforms_ynh.git synced 2024-09-03 18:36:12 +02:00
framaforms_ynh/scripts/upgrade
2024-07-14 17:20:14 +02:00

120 lines
4.6 KiB
Bash

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#=================================================
# Framaforms 2 Yakforms Backup
#=================================================
if ynh_compare_current_package_version --comparison lt --version 1.1~ynh1; then
upgrade_to_yakforms=true
else
upgrade_to_yakforms=false
fi
if [ "$upgrade_to_yakforms" = true ]; then
pushd "$install_dir/app"
ynh_setup_source --source_id="migration_script" --dest_dir="$install_dir/app"
ynh_exec_as "$app" env "PATH=$PATH" "php$phpversion" framaforms2yakforms.php backup
_ynh_exec_with_drush_php drush "@$app" dis framaforms
_ynh_exec_with_drush_php drush "@$app" pm-uninstall framaforms
_ynh_exec_with_drush_php drush "@$app" dis framaforms_share_results
_ynh_exec_with_drush_php drush "@$app" pm-uninstall framaforms_share_results
_ynh_exec_with_drush_php drush "@$app" dis framaforms_public_results
_ynh_exec_with_drush_php drush "@$app" pm-uninstall framaforms_public_results
_ynh_exec_with_drush_php drush "@$app" dis framaforms_spam
_ynh_exec_with_drush_php drush "@$app" pm-uninstall framaforms_spam
popd
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=9
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/app" --full_replace=1 --keep="sites"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# UPGRADE COMPOSER
#=================================================
ynh_script_progression --message="Upgrading Composer..." --weight=3
ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir/.composer"
#=================================================
# Framaforms 2 Yakforms Restore
#=================================================
if [ "$upgrade_to_yakforms" = true ]; then
pushd "$install_dir/app"
_ynh_exec_with_drush_php drush "@$app" en yakforms
_ynh_exec_with_drush_php drush "@$app" dis yakforms_share_results
_ynh_exec_with_drush_php drush "@$app" dis yakforms_public_results
_ynh_exec_with_drush_php drush "@$app" dis yakforms_spam
ynh_exec_as "$app" env "PATH=$PATH" "php$phpversion" framaforms2yakforms.php restore
ynh_exec_as "$app" env "PATH=$PATH" "php$phpversion" framaforms2yakforms.php clean
popd
fi
#=================================================
# UPGRADE DRUPAL
#=================================================
ynh_script_progression --message="Upgrading Drupal..." --weight=30
ynh_backup_if_checksum_is_different --file="$install_dir/app/sites/default/settings.php"
# Chown from composer/drush install
chown -R "$app:www-data" "$install_dir"
pushd "$install_dir/app"
_ynh_exec_with_drush_php drush "@$app" variable-set --exact maintenance_mode 1
_ynh_exec_with_drush_php drush "@$app" cache-clear all
# _ynh_exec_with_drush_php drush "@$app" pm-update -y drupal
# _ynh_exec_with_drush_php drush "@$app" updatedb -y
_ynh_exec_with_drush_php drush "@$app" cache-clear all
_ynh_exec_with_drush_php drush "@$app" variable-set --exact maintenance_mode 0
popd
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
chmod 600 "$install_dir/app/sites/default/settings.php"
chown "$app:$app" "$install_dir/app/sites/default/settings.php"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last