1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
limesurvey_ynh/scripts/upgrade
Félix Piédallu 09d3c1e7ca Manifest v2
2024-01-23 16:40:33 +01:00

90 lines
3.1 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..." --weight=1
# If prefix doesn't exist, create it
if [ -z "${prefix:-}" ]; then
prefix="lime_"
ynh_app_setting_set --app=$app --key=prefix --value=$prefix
fi
# if install_dir/upload is not a symlink, moving data...
if [ ! -L "$install_dir/upload" ]; then
if [ -z "$(ls -A "$data_dir/upload")" ]; then
rmdir "$data_dir/upload"
else
ynh_warn "$data_dir/upload is not empty, moving to $data_dir/upload_backup. You can decide to remove it or merge it with the new upload dir."
mv "$data_dir/upload" "$data_dir/upload_backup"
fi
mv "$install_dir/upload" "$data_dir/upload"
fi
#=================================================
# 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=1 --keep="plugins/ application/config/config.php"
ln -s "$data_dir/upload" "$install_dir/upload"
chmod 750 "$install_dir"
chmod 750 "$install_dir/tmp"
chmod 750 "$install_dir/application/config/"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
chmod 750 "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="../conf/config.php" --destination="$install_dir/application/config/config.php"
chmod 400 "$install_dir/application/config/config.php"
chown "$app:$app" "$install_dir/application/config/config.php"
#=================================================
# UPGRADE DB
#=================================================
ynh_script_progression --message="Running Database migrations..."
# Migrate DB
ynh_exec_as "$app" "php$phpversion" "$install_dir/application/commands/console.php" updatedb
#=================================================
# 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
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last