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
lapineige e27d4428e7
Remove all RemoveMe
Brute force, need to clean and check it…
2023-08-13 11:08:31 +02:00

239 lines
6.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
# Backup the current version of the app
# Restore it if the upgrade fails
}
# Exit if an error occurs during the execution of the script
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create the required permissions
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
fi
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
fi
# If data_dir doesn't exist, create it
if [ -z "$data_dir" ]; then
data_dir=/home/yunohost.app/$app
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a dedicated user (if not existing)
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
mkdir -p $data_dir
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir"
#=================================================
# Framaforms 2 Yakforms Backup
#=================================================
upgrade_to_yakforms=false
then
update-alternatives --set php /usr/bin/php$phpversion
upgrade_to_yakforms=true
pushd "$install_dir"
ynh_exec_as $app env PATH=$PATH php framaforms2yakforms.php backup
ynh_exec_as $app env PATH=$PATH drush @$app dis framaforms
ynh_exec_as $app env PATH=$PATH drush @$app pm-uninstall framaforms
ynh_exec_as $app env PATH=$PATH drush @$app dis framaforms_share_results
ynh_exec_as $app env PATH=$PATH drush @$app pm-uninstall framaforms_share_results
ynh_exec_as $app env PATH=$PATH drush @$app dis framaforms_public_results
ynh_exec_as $app env PATH=$PATH drush @$app pm-uninstall framaforms_public_results
ynh_exec_as $app env PATH=$PATH drush @$app dis framaforms_spam
ynh_exec_as $app env PATH=$PATH drush @$app pm-uninstall framaforms_spam
popd
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
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"
fi
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# UPGRADE COMPOSER
#=================================================
ynh_script_progression --message="Upgrading Composer..." --weight=3
ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir/.composer"
export PATH="$install_dir/.composer/vendor/bin:$PATH"
#=================================================
# Framaforms 2 Yakforms Restore
#=================================================
if [ "$upgrade_to_yakforms" = true ]
then
update-alternatives --set php /usr/bin/php$phpversion
pushd "$install_dir"
ynh_exec_as $app env PATH=$PATH drush @$app en yakforms
ynh_exec_as $app env PATH=$PATH drush @$app dis yakforms_share_results
ynh_exec_as $app env PATH=$PATH drush @$app dis yakforms_public_results
ynh_exec_as $app env PATH=$PATH drush @$app dis yakforms_spam
ynh_exec_as $app env PATH=$PATH php framaforms2yakforms.php restore
ynh_exec_as $app env PATH=$PATH php framaforms2yakforms.php clean
popd
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
fi
#=================================================
# UPGRADE DRUPAL
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading Drupal..." --weight=30
ynh_backup_if_checksum_is_different --file="$install_dir/app/sites/default/settings.php"
update-alternatives --set php /usr/bin/php$phpversion
pushd "$install_dir"
ynh_exec_as $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1
ynh_exec_as $app env PATH=$PATH drush @$app cache-clear all
# ynh_exec_as $app env PATH=$PATH drush @$app pm-update -y drupal
# ynh_exec_as $app env PATH=$PATH drush @$app updatedb -y
ynh_exec_as $app env PATH=$PATH drush @$app cache-clear all
ynh_exec_as $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0
popd
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
fi
#=================================================
# 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"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last