Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for custom data directory #407

Open
wants to merge 10 commits into
base: testing
Choose a base branch
from
10 changes: 10 additions & 0 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-bz2 php${YNH_P

pkg_dependencies="imagemagick libmagickcore-6.q16-6-extra acl tar smbclient at $php_dependencies"


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
#=================================================
Expand Down
2 changes: 2 additions & 0 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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

#=================================================
Expand Down
2 changes: 2 additions & 0 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,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

Expand Down
4 changes: 2 additions & 2 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,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
Expand Down