1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00

[fix] Upgrade

This commit is contained in:
ljf 2018-03-14 19:05:43 +01:00
parent 54285e1886
commit 74f74e845c
3 changed files with 54 additions and 40 deletions

View file

@ -2,7 +2,7 @@
"name": "LimeSurvey",
"id": "limesurvey",
"packaging_format": 1,
"version": "3.5.0-1",
"version": "3.5.0-4",
"description": {
"en": "LimeSurvey is used to create advanced poll.",
"fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne."

View file

@ -88,45 +88,52 @@ ynh_exec_as() {
}
# TODO support SOURCE_ID
# usage: ynh_save_persistent MODE RELATIVE_PATH
ynh_save_persistent () {
local TYPE=$1
local DIR=/tmp/ynh-persistent/$TYPE/$app/app
mkdir -p $DIR
touch $DIR/dir_names
shift
i=1
for PERSISTENT_DIR in $@;
do
if [ -e $final_path/$PERSISTENT_DIR ]; then
mv $final_path/$PERSISTENT_DIR $DIR/$i
echo -n '$PERSISTENT_DIR ' >> $DIR/dir_names
((i++))
fi
done
local DIR=/tmp/ynh-persistent/$app
set +u
i=${#YNH_PERSISTENT_DIR[@]}
i=${i:-0}
set -u
[ "$i" -eq "0" ] && ynh_secure_remove $DIR && mkdir -p $DIR
if [ -e $final_path/$2 ]; then
mv $final_path/$2 $DIR/$i
YNH_PERSISTENT_MODE[$i]=$1
YNH_PERSISTENT_DIR[$i]=$2
fi
}
# TODO support SOURCE_ID
ynh_keep_if_no_upgrade () {
for elt in $@;
do
ynh_save_persistent KEEP_IF_NO_UPGRADE $elt
done
}
ynh_keep () {
for elt in $@;
do
ynh_save_persistent KEEP $elt
done
}
# usage: ynh_restore_persistent
ynh_restore_persistent () {
local TYPE=$1
local DIR=/tmp/ynh-persistent/$TYPE/$app/app
shift
if [ -d $DIR ]; then
i=1
for PERSISTENT_DIR in $(cat $DIR/dir_names);
local DIR=/tmp/ynh-persistent/$app
if [ -d $DIR ]; then
i=0
for PERSISTENT_DIR in "${YNH_PERSISTENT_DIR[@]}";
do
if [ "$TYPE" = "modules" ]; then
for updated_subdir in $(ls $final_path/$PERSISTENT_DIR);
do
ynh_secure_remove $DIR/$i/$updated_subdir
done
fi
if [ -d $DIR/$i ]; then
mv $DIR/$i/* $final_path/$PERSISTENT_DIR/ 2> /dev/null || true
if [ "${YNH_PERSISTENT_MODE[$i]}" = "KEEP_IF_NO_UPGRADE" ]; then
if [ ! -e $final_path/$PERSISTENT_DIR ]; then
mv $DIR/$i $final_path/$PERSISTENT_DIR
fi
else
mv $DIR/$i $final_path/$PERSISTENT_DIR 2> /dev/null || true
if [ -e $final_path/$PERSISTENT_DIR ]; then
ynh_secure_remove $final_path/$PERSISTENT_DIR
fi
mv $DIR/$i $final_path/$PERSISTENT_DIR
fi
((i++))
((i+=1))
done
ynh_secure_remove $DIR
fi

View file

@ -57,7 +57,6 @@ if ynh_version_le "2.0.5" ; then
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
ynh_install_app_dependencies $pkg_dependencies
# Move the upload dir to final_path if needed
@ -74,9 +73,18 @@ if ynh_version_le "2.0.5" ; then
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 in backup dir
mv $final_path/upload/templates /home/yunohost.backup/$app-old-templates
# 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
#=================================================
@ -86,16 +94,15 @@ fi
#=================================================
# Backup config, plugins and themes and delete previous files
ynh_save_persistent modules themes plugins
ynh_save_persistent data application/config/config.php upload
ynh_keep_if_no_upgrade themes/admin/* themes/question/* themes/survey/* plugins/*
ynh_keep application/config/config.php 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 modules
ynh_restore_persistent data
ynh_restore_persistent
#=================================================
# NGINX CONFIGURATION
@ -126,7 +133,7 @@ set_permissions
# Migrate DB
cd $final_path/application/commands
ynh_exec_as "$app" php console.php update
ynh_exec_as "$app" php console.php updatedb
#=================================================
# RELOAD NGINX