1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/civicrm_drupal7_ynh.git synced 2024-09-03 18:16:19 +02:00
civicrm_drupal7_ynh/scripts/upgrade
2024-02-01 23:23:18 +01:00

93 lines
3.4 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/34-mysql_$app"
yunohost tools regen-conf mysql --force
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" --full_replace=1
ynh_setup_source --dest_dir="$install_dir/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n"
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..."
ynh_install_composer --workdir="$install_dir/.composer"
export PATH="$install_dir/.composer/vendor/bin:$PATH"
#=================================================
# UPGRADE DRUPAL
#=================================================
ynh_script_progression --message="Upgrading Drupal..."
ynh_backup_if_checksum_is_different --file="$install_dir/$app/sites/default/settings.php"
ynh_backup_if_checksum_is_different --file="$install_dir/$app/sites/default/civicrm.settings.php"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
pushd "$install_dir"
_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" cache-clear all
_ynh_exec_with_drush_php drush "@$app" l10n-update-refresh
_ynh_exec_with_drush_php drush "@$app" l10n-update
_ynh_exec_with_drush_php drush --include="$install_dir/$app/sites/all/modules/civicrm/drupal/drush" "@$app" -y civicrm-upgrade-db
_ynh_exec_with_drush_php drush "@$app" variable-set --exact maintenance_mode 0
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
popd
ynh_store_file_checksum --file="$install_dir/$app/sites/default/settings.php"
ynh_store_file_checksum --file="$install_dir/$app/sites/default/civicrm.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
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a Cron job
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"