diff --git a/conf/.env.example b/conf/.env.example index 8d1f843..8c39b67 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -33,7 +33,7 @@ TIMEZONE=UTC # folders in which the files will be stored LYCHEE_DIST="__FINALPATH__/public/dist/" -LYCHEE_UPLOADS="__PUBLIC_PATH__/uploads/" +LYCHEE_UPLOADS="__DATADIR__/uploads/" # url to access those files # LYCHEE_DIST_URL="dist/" diff --git a/conf/nginx.conf b/conf/nginx.conf index b1dd405..508f7a4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -31,7 +31,7 @@ location ^~ __PATH__/ { } location __PATH__/uploads/ { - alias __PUBLIC_PATH__/uploads/ ; + alias __DATADIR__/uploads/ ; } # Include SSOWAT user panel. diff --git a/scripts/backup b/scripts/backup index f57412d..56014a2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -public_path=$(ynh_app_setting_get --app=$app --key=public_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -44,7 +44,7 @@ ynh_backup --src_path="$final_path" # BACKUP MEDIA FOLDER #================================================= -ynh_backup --src_path="$public_path" --is_big +ynh_backup --src_path="$datadir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index f76a1eb..4f82112 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -public_path=$(ynh_app_setting_get --app=$app --key=public_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP diff --git a/scripts/install b/scripts/install index 6e55c2f..71fa821 100755 --- a/scripts/install +++ b/scripts/install @@ -88,15 +88,15 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -public_path=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=public_path --value=$public_path +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir -mkdir -p $public_path/uploads -mkdir -p $public_path/uploads/{big,import,medium,raw,small,thumb} +mkdir -p $datadir/uploads +mkdir -p $datadir/uploads/{big,import,medium,raw,small,thumb} -chmod 750 "$public_path" -chmod -R o-rwx "$public_path" -chown -R $app:www-data "$public_path" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # NGINX CONFIGURATION diff --git a/scripts/remove b/scripts/remove index c6c1d45..08d2f7a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -public_path=$(ynh_app_setting_get --app=$app --key=public_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name @@ -32,6 +32,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=3 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the app data directory with the command `yunohost app remove --purge` +if [ "$YNH_APP_PURGE" == true ] +then + ynh_script_progression --message="Removing $app data directory..." --weight=2 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE THE MYSQL DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index 51a327f..d6ebb19 100755 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -public_path=$(ynh_app_setting_get --app=$app --key=public_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -74,11 +74,13 @@ chown -R $app:www-data "$final_path" ynh_script_progression --message="Restoring the data directory..." # 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="$public_path" --not_mandatory +ynh_restore_file --origin_path="$datadir" --not_mandatory -chmod 755 "$public_path" -chmod -R o-rwx "$public_path" -chown -R $app:www-data "$public_path" +mkdir -p $datadir + +chmod 755 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index 462c2a6..78d1f6f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -public_path=$(ynh_app_setting_get --app=$app --key=public_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) phpversion=$YNH_PHP_VERSION @@ -61,14 +61,14 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -# If new public_path doesn't exist, create it +# If new datadir doesn't exist, create it if [ -z "/home/yunohost.app/$app" ]; then - public_path=/home/yunohost.app/$app - mkdir -p $public_path - chmod 755 $public_path - chown -R $app:www-data $public_path - ynh_app_setting_set --app=$app --key=public_path --value=$public_path - cp -a "$final_path/public/uploads" "$public_path/uploads" + datadir=/home/yunohost.app/$app + mkdir -p $datadir + chmod 755 $datadir + chown -R $app:www-data $datadir + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + cp -a "$final_path/public/uploads" "$datadir/uploads" fi # Cleaning legacy permissions