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

set --purge function

This commit is contained in:
ericgaspar 2021-08-18 22:44:54 +02:00
parent 507939ff24
commit a285990f35
No known key found for this signature in database
GPG key ID: 574F281483054D44
8 changed files with 39 additions and 26 deletions

View file

@ -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/"

View file

@ -31,7 +31,7 @@ location ^~ __PATH__/ {
}
location __PATH__/uploads/ {
alias __PUBLIC_PATH__/uploads/ ;
alias __DATADIR__/uploads/ ;
}
# Include SSOWAT user panel.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
#=================================================

View file

@ -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

View file

@ -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