mirror of
https://github.com/YunoHost-Apps/limesurvey_ynh.git
synced 2024-09-03 19:36:32 +02:00
156 lines
5.3 KiB
Bash
156 lines
5.3 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source /usr/share/yunohost/helpers
|
|
source _common.sh
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
export app=$YNH_APP_INSTANCE_NAME
|
|
|
|
export domain=$(ynh_app_setting_get $app domain)
|
|
export path_url=$(ynh_app_setting_get $app path)
|
|
export admin=$(ynh_app_setting_get $app admin)
|
|
export final_path=$(ynh_app_setting_get $app final_path)
|
|
export is_public=$(ynh_app_setting_get $app is_public)
|
|
export prefix=$(ynh_app_setting_get $app prefix)
|
|
export db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
|
export db_name=$(ynh_app_setting_get $app db_name)
|
|
export db_user=$(ynh_app_setting_get $app db_user)
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
ynh_abort_if_up_to_date
|
|
|
|
#=================================================
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
#=================================================
|
|
|
|
# Backup the current version of the app
|
|
ynh_backup_before_upgrade
|
|
ynh_clean_setup () {
|
|
# restore it if the upgrade fails
|
|
ynh_restore_upgradebackup
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# CHECK THE PATH
|
|
#=================================================
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
|
|
|
#=================================================
|
|
# STEP Migrations
|
|
#=================================================
|
|
if ynh_version_le "2.0.5" ; then
|
|
is_public=${is_public:-0}
|
|
prefix=${prefix:-prefix_}
|
|
db_name=${db_name:-$app}
|
|
final_path=$(ynh_app_setting_get $app local_path)
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
# Move the upload dir to final_path if needed
|
|
# The upload dir can't be symlinked in home (not supported by LS)
|
|
upload_path=/home/yunohost.app/$app/upload
|
|
if [ -h $final_path/upload ]; then
|
|
rm $final_path/upload
|
|
mv $upload_path $final_path/
|
|
fi
|
|
|
|
ynh_app_setting_delete $app skipped_uris
|
|
ynh_sso_access "/index.php?r=admin,/index.php?r=plugins,/scripts"
|
|
|
|
ynh_configure migrations/2.0.5.sql ./2.0.5.sql
|
|
mysql -u $app -p$db_pwd $db_name < ./2.0.5.sql
|
|
fi
|
|
if ynh_version_le "2.62.2-1" ; then
|
|
is_public=${is_public:-0}
|
|
prefix=${prefix:-prefix_}
|
|
db_name=${db_name:-$app}
|
|
final_path=$(ynh_app_setting_get $app local_path)
|
|
ynh_save_args path_url is_public prefix db_name final_path db_user
|
|
fi
|
|
if ynh_version_le "2.62.2-2" ; then
|
|
# Move old templates and themes in backup dir
|
|
mv $final_path/upload/templates /home/yunohost.backup/$app.bkp/old-templates
|
|
mkdir -p /home/yunohost.backup/$app.bkp/old-themes
|
|
mv $final_path/themes/* /home/yunohost.backup/$app.bkp/old-themes/
|
|
fi
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
# Backup config, plugins and themes and delete previous files
|
|
ynh_keep_if_no_upgrade themes/admin/*
|
|
ynh_keep_if_no_upgrade themes/question/*
|
|
ynh_keep_if_no_upgrade themes/survey/*
|
|
ynh_keep_if_no_upgrade plugins/*
|
|
ynh_keep application/config/config.php
|
|
ynh_keep upload
|
|
|
|
# Copie new files and restore config, plugins, upload and themes
|
|
ynh_secure_remove $final_path
|
|
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
|
|
|
# Restore config, plugins and themes
|
|
ynh_restore_persistent
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# CREATE DEDICATED USER
|
|
#=================================================
|
|
|
|
ynh_system_user_create $app # Create the dedicated user, if not exist
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
|
|
|
|
#=================================================
|
|
# SECURING FILES AND DIRECTORIES
|
|
#=================================================
|
|
set_permissions
|
|
|
|
#=================================================
|
|
# UPGRADE DB
|
|
#=================================================
|
|
|
|
# Migrate DB
|
|
cd $final_path
|
|
ynh_exec_as "$app" php application/commands/console.php updatedb
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
|
|
ynh_system_reload nginx
|
|
|
|
#=================================================
|
|
# Send message to the admin
|
|
#=================================================
|
|
|
|
if ynh_version_le "2.62.2-2" ; then
|
|
message="LimeSurvey has been upgraded from version to version 3, note this new version change completely the survey themes system. If you have added or created manually some templates they won't be available in your LimeSurvey, a copy of their source code has been done in /home/yunohost.backup/$app-old-templates/. See https://manual.limesurvey.org/New_Template_System_in_LS3.x"
|
|
ynh_warn "$message"
|
|
ynh_send_readme_to_admin "$message" "$admin"
|
|
fi
|