2018-04-29 13:00:03 +02:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
2020-03-29 05:02:23 +02:00
source /usr/share/yunohost/helpers
2018-04-29 13:00:03 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2024-08-30 22:55:42 +02:00
# ynh_script_progression "Ensuring downward compatibility..."
2021-03-23 20:51:39 +01:00
2018-04-29 13:00:03 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-08-30 22:55:42 +02:00
ynh_script_progression "Upgrading source files..."
2018-04-29 13:00:03 +02:00
2024-03-16 13:58:59 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2024-08-30 22:55:42 +02:00
ynh_setup_source --dest_dir="$install_dir/app" --full_replace --keep="sites"
2019-06-14 18:57:58 +02:00
2024-08-30 22:55:42 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
2024-03-16 13:58:59 +01:00
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
2021-05-15 19:19:38 +02:00
2018-04-29 13:00:03 +02:00
#=================================================
2019-06-19 02:18:00 +02:00
# UPGRADE COMPOSER
#=================================================
2024-08-30 22:55:42 +02:00
ynh_script_progression "Upgrading Composer..."
2019-06-19 02:18:00 +02:00
2024-08-30 22:55:42 +02:00
ynh_composer_install
ynh_composer_exec install --no-dev # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir="$install_dir/.composer"
2020-06-10 02:38:55 +02:00
2019-06-19 02:18:00 +02:00
#=================================================
# UPGRADE DRUPAL
#=================================================
2024-08-30 22:55:42 +02:00
ynh_script_progression "Upgrading Drupal..."
2019-06-19 02:18:00 +02:00
2024-08-30 22:55:42 +02:00
ynh_backup_if_checksum_is_different "$install_dir/app/sites/default/settings.php"
2019-08-05 03:02:23 +02:00
2024-03-16 14:25:35 +01:00
# Chown from composer/drush install
2024-08-30 22:55:42 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
2024-03-16 13:58:59 +01:00
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" 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
2018-04-29 13:00:03 +02:00
2019-06-14 18:57:58 +02:00
#=================================================
2021-05-15 19:19:38 +02:00
# UPDATE A CONFIG FILE
2019-06-14 18:57:58 +02:00
#=================================================
2024-08-30 22:55:42 +02:00
ynh_script_progression "Updating configuration..."
2018-04-29 13:00:03 +02:00
2024-08-30 22:55:42 +02:00
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/app/sites/default/settings.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/app/sites/default/settings.php"
2018-04-29 13:00:03 +02:00
#=================================================
2024-03-16 13:58:59 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2018-04-29 13:00:03 +02:00
#=================================================
2024-08-30 22:55:42 +02:00
ynh_script_progression "Upgrading system configurations related to $app..."
2024-03-16 13:58:59 +01:00
# Create a dedicated PHP-FPM config
2024-08-30 22:55:42 +02:00
ynh_config_add_phpfpm
2024-03-16 13:58:59 +01:00
# Create a dedicated NGINX config
2024-08-30 22:55:42 +02:00
ynh_config_add_nginx
2019-06-14 18:57:58 +02:00
2024-08-30 22:55:42 +02:00
ynh_config_add --template="cron" --destination="/etc/cron.d/$app"
2018-04-29 13:00:03 +02:00
2019-06-14 18:57:58 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2018-04-29 13:00:03 +02:00
2024-08-30 22:55:42 +02:00
ynh_script_progression "Upgrade of $app completed"