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

[fix] Restore and some error in upgrade

This commit is contained in:
ljf 2018-03-14 03:32:46 +01:00
parent c513ef35af
commit f2edb507ad
2 changed files with 24 additions and 8 deletions

View file

@ -53,8 +53,8 @@ ynh_export () {
} }
# Check the path doesn't exist # Check the path doesn't exist
# usage: ynh_local_path_available PATH # usage: ynh_final_path_available PATH
ynh_local_path_available () { ynh_final_path_available () {
if [ -e "$1" ] if [ -e "$1" ]
then then
ynh_die "This path '$1' already contains a folder" ynh_die "This path '$1' already contains a folder"
@ -99,8 +99,8 @@ ynh_save_persistent () {
i=1 i=1
for PERSISTENT_DIR in $@; for PERSISTENT_DIR in $@;
do do
if [ -e $local_path/$PERSISTENT_DIR ]; then if [ -e $final_path/$PERSISTENT_DIR ]; then
mv $local_path/$PERSISTENT_DIR $DIR/$i mv $final_path/$PERSISTENT_DIR $DIR/$i
echo -n '$PERSISTENT_DIR ' >> $DIR/dir_names echo -n '$PERSISTENT_DIR ' >> $DIR/dir_names
((i++)) ((i++))
fi fi
@ -117,15 +117,15 @@ ynh_restore_persistent () {
for PERSISTENT_DIR in $(cat $DIR/dir_names); for PERSISTENT_DIR in $(cat $DIR/dir_names);
do do
if [ "$TYPE" = "modules" ]; then if [ "$TYPE" = "modules" ]; then
for updated_subdir in $(ls $local_path/$PERSISTENT_DIR); for updated_subdir in $(ls $final_path/$PERSISTENT_DIR);
do do
ynh_secure_remove $DIR/$i/$updated_subdir ynh_secure_remove $DIR/$i/$updated_subdir
done done
fi fi
if [ -d $DIR/$i ]; then if [ -d $DIR/$i ]; then
mv $DIR/$i/* $local_path/$PERSISTENT_DIR/ 2> /dev/null || true mv $DIR/$i/* $final_path/$PERSISTENT_DIR/ 2> /dev/null || true
else else
mv $DIR/$i $local_path/$PERSISTENT_DIR 2> /dev/null || true mv $DIR/$i $final_path/$PERSISTENT_DIR 2> /dev/null || true
fi fi
((i++)) ((i++))
done done
@ -344,7 +344,7 @@ ynh_version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
# #
# usage: ynh_version_le "0.5" # usage: ynh_version_le "0.5"
ynh_version_le() { ynh_version_le() {
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) local version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
ynh_version_gt "$1" "${version}" ynh_version_gt "$1" "${version}"
} }
@ -370,3 +370,15 @@ is_jessie () {
fi fi
} }
# Reload (or other actions) a service and print a log in case of failure.
#
# usage: ynh_system_reload service_name [action]
# | arg: service_name - Name of the service to reload
# | arg: action - Action to perform with systemctl. Default: reload
ynh_system_reload () {
local service_name=$1
local action=${2:-reload}
# Reload, restart or start and print the log if the service fail to start or reload
systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false)
}

View file

@ -90,6 +90,10 @@ ynh_save_persistent data application/config/config.php upload
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
ynh_restore_persistent modules
ynh_restore_persistent data
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================