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:
parent
54285e1886
commit
74f74e845c
3 changed files with 54 additions and 40 deletions
|
@ -2,7 +2,7 @@
|
||||||
"name": "LimeSurvey",
|
"name": "LimeSurvey",
|
||||||
"id": "limesurvey",
|
"id": "limesurvey",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"version": "3.5.0-1",
|
"version": "3.5.0-4",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "LimeSurvey is used to create advanced poll.",
|
"en": "LimeSurvey is used to create advanced poll.",
|
||||||
"fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne."
|
"fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne."
|
||||||
|
|
|
@ -88,45 +88,52 @@ ynh_exec_as() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# TODO support SOURCE_ID
|
# usage: ynh_save_persistent MODE RELATIVE_PATH
|
||||||
ynh_save_persistent () {
|
ynh_save_persistent () {
|
||||||
local TYPE=$1
|
local TYPE=$1
|
||||||
local DIR=/tmp/ynh-persistent/$TYPE/$app/app
|
local DIR=/tmp/ynh-persistent/$app
|
||||||
mkdir -p $DIR
|
set +u
|
||||||
touch $DIR/dir_names
|
i=${#YNH_PERSISTENT_DIR[@]}
|
||||||
shift
|
i=${i:-0}
|
||||||
i=1
|
set -u
|
||||||
for PERSISTENT_DIR in $@;
|
[ "$i" -eq "0" ] && ynh_secure_remove $DIR && mkdir -p $DIR
|
||||||
do
|
if [ -e $final_path/$2 ]; then
|
||||||
if [ -e $final_path/$PERSISTENT_DIR ]; then
|
mv $final_path/$2 $DIR/$i
|
||||||
mv $final_path/$PERSISTENT_DIR $DIR/$i
|
YNH_PERSISTENT_MODE[$i]=$1
|
||||||
echo -n '$PERSISTENT_DIR ' >> $DIR/dir_names
|
YNH_PERSISTENT_DIR[$i]=$2
|
||||||
((i++))
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO support SOURCE_ID
|
ynh_keep_if_no_upgrade () {
|
||||||
ynh_restore_persistent () {
|
for elt in $@;
|
||||||
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);
|
|
||||||
do
|
do
|
||||||
if [ "$TYPE" = "modules" ]; then
|
ynh_save_persistent KEEP_IF_NO_UPGRADE $elt
|
||||||
for updated_subdir in $(ls $final_path/$PERSISTENT_DIR);
|
|
||||||
do
|
|
||||||
ynh_secure_remove $DIR/$i/$updated_subdir
|
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
ynh_keep () {
|
||||||
|
for elt in $@;
|
||||||
|
do
|
||||||
|
ynh_save_persistent KEEP $elt
|
||||||
|
done
|
||||||
|
}
|
||||||
|
# usage: ynh_restore_persistent
|
||||||
|
ynh_restore_persistent () {
|
||||||
|
local DIR=/tmp/ynh-persistent/$app
|
||||||
|
if [ -d $DIR ]; then
|
||||||
|
i=0
|
||||||
|
for PERSISTENT_DIR in "${YNH_PERSISTENT_DIR[@]}";
|
||||||
|
do
|
||||||
|
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
|
fi
|
||||||
if [ -d $DIR/$i ]; then
|
|
||||||
mv $DIR/$i/* $final_path/$PERSISTENT_DIR/ 2> /dev/null || true
|
|
||||||
else
|
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
|
fi
|
||||||
((i++))
|
mv $DIR/$i $final_path/$PERSISTENT_DIR
|
||||||
|
fi
|
||||||
|
((i+=1))
|
||||||
done
|
done
|
||||||
ynh_secure_remove $DIR
|
ynh_secure_remove $DIR
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -57,7 +57,6 @@ if ynh_version_le "2.0.5" ; then
|
||||||
prefix=${prefix:-prefix_}
|
prefix=${prefix:-prefix_}
|
||||||
db_name=${db_name:-$app}
|
db_name=${db_name:-$app}
|
||||||
final_path=$(ynh_app_setting_get $app local_path)
|
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
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
# Move the upload dir to final_path if needed
|
# 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
|
ynh_configure migrations/2.0.5.sql ./2.0.5.sql
|
||||||
mysql -u $app -p$db_pwd $db_name < ./2.0.5.sql
|
mysql -u $app -p$db_pwd $db_name < ./2.0.5.sql
|
||||||
fi
|
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
|
if ynh_version_le "2.62.2-2" ; then
|
||||||
# Move old templates in backup dir
|
# Move old templates and themes in backup dir
|
||||||
mv $final_path/upload/templates /home/yunohost.backup/$app-old-templates
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,16 +94,15 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Backup config, plugins and themes and delete previous files
|
# Backup config, plugins and themes and delete previous files
|
||||||
ynh_save_persistent modules themes plugins
|
ynh_keep_if_no_upgrade themes/admin/* themes/question/* themes/survey/* plugins/*
|
||||||
ynh_save_persistent data application/config/config.php upload
|
ynh_keep application/config/config.php upload
|
||||||
|
|
||||||
# Copie new files and restore config, plugins, upload and themes
|
# Copie new files and restore config, plugins, upload and themes
|
||||||
ynh_secure_remove $final_path
|
ynh_secure_remove $final_path
|
||||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
||||||
|
|
||||||
# Restore config, plugins and themes
|
# Restore config, plugins and themes
|
||||||
ynh_restore_persistent modules
|
ynh_restore_persistent
|
||||||
ynh_restore_persistent data
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -126,7 +133,7 @@ set_permissions
|
||||||
|
|
||||||
# Migrate DB
|
# Migrate DB
|
||||||
cd $final_path/application/commands
|
cd $final_path/application/commands
|
||||||
ynh_exec_as "$app" php console.php update
|
ynh_exec_as "$app" php console.php updatedb
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue