From 4629333cd571522d1afc60cf083e42b9b2c5bf8a Mon Sep 17 00:00:00 2001 From: Tobias Ollive Date: Fri, 14 May 2021 13:28:38 +0200 Subject: [PATCH 1/2] add support for custom data directory --- scripts/_common.sh | 10 ++++++++++ scripts/backup | 4 +++- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index adf5f21a..2647a5d2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,16 @@ pkg_dependencies="imagemagick acl tar smbclient at" YNH_PHP_VERSION="7.3" extra_php_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-smbclient php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-bcmath" + +set_datadir() { + if [[ -f $final_path/config/config.php ]]; then + datadir=$(grep datadirectory < $final_path/config/config.php | sed "s/.*=>.'\([^']*\)'.*/\1/") + else + datadir="/home/yunohost.app/$app/data" + fi +} + + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 7ed3c7fe..69831b74 100755 --- a/scripts/backup +++ b/scripts/backup @@ -84,7 +84,9 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= ynh_print_info --message="Backing up data directory..." -ynh_backup --src_path="/home/yunohost.app/${app}/data" --is_big +set_datadir + +ynh_backup --src_path="$datadir" --is_big #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 44f8384f..b303aa9d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -121,7 +121,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Restoring data directory..." --weight=2 -datadir="/home/yunohost.app/$app/data" +set_datadir # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$datadir" --not_mandatory diff --git a/scripts/upgrade b/scripts/upgrade index 5805432e..e946a0df 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -202,8 +202,8 @@ local mount_id=$(exec_occ files_external:create --output=json \ && ynh_print_warn --message="Unable to create external storage" \ || exec_occ files_external:option "$mount_id" enable_sharing true } -# Define app's data directory -datadir="/home/yunohost.app/$app/data" +# Define app's data directory (defined in _common.sh) +set_datadir if [ "$upgrade_type" == "UPGRADE_APP" ] then From 921b83c56de79176a5fdc6a8d3fe8a399503f0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 16 Jul 2022 22:57:58 +0200 Subject: [PATCH 2/2] set datadir --- scripts/backup | 2 ++ scripts/restore | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/backup b/scripts/backup index 41274203..ebf77613 100755 --- a/scripts/backup +++ b/scripts/backup @@ -85,6 +85,8 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= ynh_print_info --message="Backing up data directory..." +set_datadir + ynh_backup --src_path="$datadir" --is_big #================================================= diff --git a/scripts/restore b/scripts/restore index 425e5809..1775ff2a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -120,6 +120,8 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Restoring data directory..." --weight=2 +set_datadir + # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$datadir" --not_mandatory