mirror of
https://github.com/YunoHost-Apps/lufi_ynh.git
synced 2024-09-03 19:36:28 +02:00
Add purge datadir
This commit is contained in:
parent
bfda866a29
commit
3465af26b1
7 changed files with 35 additions and 24 deletions
|
@ -22,7 +22,7 @@
|
||||||
"email": "win10@tutanota.com, cyp@rouquin.me"
|
"email": "win10@tutanota.com, cyp@rouquin.me"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.2.4"
|
"yunohost": ">= 4.2.8"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -47,7 +47,7 @@ ynh_backup --src_path="$final_path"
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$public_path" --is_big
|
ynh_backup --src_path="$datadir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -35,7 +35,6 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
public_path=$(ynh_app_setting_get --app=$app --key=public_path)
|
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||||
max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size)
|
max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size)
|
||||||
|
|
||||||
|
|
|
@ -114,14 +114,14 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a data directory..."
|
ynh_script_progression --message="Creating a data directory..."
|
||||||
|
|
||||||
public_path=/home/yunohost.app/$app
|
datadir=/home/yunohost.app/$app
|
||||||
ynh_app_setting_set --app=$app --key=public_path --value=$public_path
|
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||||
|
|
||||||
mkdir -p $public_path
|
mkdir -p $datadir
|
||||||
|
|
||||||
chmod 755 "$public_path"
|
chmod 755 "$datadir"
|
||||||
chmod -R o-rwx "$public_path"
|
chmod -R o-rwx "$datadir"
|
||||||
chown -R $app:www-data "$public_path"
|
chown -R $app:www-data "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
|
|
@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -67,6 +68,17 @@ ynh_script_progression --message="Removing app main directory..."
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
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 NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_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_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
@ -79,13 +79,13 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..."
|
ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$public_path" --not_mandatory
|
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p $public_path
|
mkdir -p $datadir
|
||||||
|
|
||||||
chmod 750 "$public_path"
|
chmod 750 "$datadir"
|
||||||
chmod -R o-rwx "$public_path"
|
chmod -R o-rwx "$datadir"
|
||||||
chown -R $app:www-data "$public_path"
|
chown -R $app:www-data "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
|
|
@ -21,7 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_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)
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
|
@ -52,11 +52,11 @@ if [ -z "$final_path" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If public_path doesn't exist, create it
|
# If datadir doesn't exist, create it
|
||||||
if [ -z "$public_path" ]; then
|
if [ -z "$datadir" ]; then
|
||||||
public_path=/home/yunohost.app/$app
|
datadir=/home/yunohost.app/$app
|
||||||
mkdir -p $public_path
|
mkdir -p $datadir
|
||||||
ynh_app_setting_set --app=$app --key=public_path --value=$public_path
|
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$max_file_size" ]; then
|
if [ -z "$max_file_size" ]; then
|
||||||
|
@ -184,8 +184,8 @@ ynh_script_progression --message="Securing files and directories..."
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R $app:www-data $final_path
|
chown -R $app:www-data $final_path
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data $public_path
|
chown -R $app:www-data $datadir
|
||||||
chmod 755 $public_path
|
chmod 755 $datadir
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
Loading…
Add table
Reference in a new issue