#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source ynh_add_swap source /usr/share/yunohost/helpers #================================================= # STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="app composer.json" ynh_store_file_checksum --file="$install_dir/composer.json" mkdir -p "$install_dir/$app" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # 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 #================================================= # SPECIFIC UPGRADE #================================================= # ADD SWAP #================================================= ynh_script_progression --message="Adding swap..." --weight=1 if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ]; then ynh_add_swap --size=$swap_needed fi #================================================= # UPGRADE COMPOSER #================================================= ynh_script_progression --message="Upgrading Composer..." --weight=3 mkdir -p "$install_dir/.composer" ynh_add_config --template="composer.json" --destination="$install_dir/composer.json" ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$install_dir" --commands="update" export PATH="$install_dir/vendor/bin:$PATH" #================================================= # UPGRADE DRUPAL #================================================= ynh_script_progression --message="Upgrading Drupal..." --weight=3 ynh_backup_if_checksum_is_different --file="$install_dir/$app/sites/default/settings.php" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" pushd "$install_dir" _ynh_exec_with_drush_php drush "@$app.prod" state:set system.maintenance_mode 1 --input-format=integer _ynh_exec_with_drush_php "php$phpversion" composer.phar update drupal/core webflo/drupal-core-require-dev --with-dependencies _ynh_exec_with_drush_php "php$phpversion" composer.phar update --with-dependencies _ynh_exec_with_drush_php drush "@$app.prod" -y updatedb _ynh_exec_with_drush_php drush "@$app.prod" cache:rebuild _ynh_exec_with_drush_php drush "@$app.prod" state:set system.maintenance_mode 0 --input-format=integer popd #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= ynh_script_progression --message="Storing the config file checksum..." --weight=1 # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$install_dir/$app/sites/default/settings.php" chmod 400 "$install_dir/$app/sites/default/settings.php" chown $app:$app "$install_dir/$app/sites/default/settings.php" #================================================= # SETUP THE CRON FILE #================================================= ynh_script_progression --message="Setting up the cron file" --weight=1 ynh_add_config --template="cron" --destination="/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last