mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
90 lines
2.7 KiB
Bash
90 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
#=================================================
|
|
# CHECK IF ARGUMENTS ARE CORRECT
|
|
#=================================================
|
|
|
|
final_path=/opt/yunohost/$app
|
|
config_file="$final_path/live/.env"
|
|
|
|
if [ ! -f $config_file ]
|
|
then
|
|
ynh_die --message="Standard Notes - Extensions can not be removed." --ret_code=1
|
|
fi
|
|
|
|
#=================================================
|
|
# CHECK IF AN ACTION HAS TO BE DONE
|
|
#=================================================
|
|
|
|
install_extensions_old=$(ynh_app_setting_get --app=$app --key=install_extensions)
|
|
|
|
if [ $install_extensions_old -eq 0 ]
|
|
then
|
|
ynh_die --message="Standard Notes - Extensions should not be installed." --ret_code=0
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC ACTION
|
|
#=================================================
|
|
# MOVE TO PUBLIC OR PRIVATE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Remove Standard Notes - Extensions ..." --weight=5
|
|
|
|
ynh_replace_string --match_string="^RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=" --target_file="$config_file"
|
|
|
|
if [ "$path_url" = "/" ]
|
|
then
|
|
path=""
|
|
else
|
|
path=$path_url
|
|
fi
|
|
|
|
find "$final_path/live/public/extensions/src/" -name "*.json" -print0 | while read -d $'\0' file
|
|
do
|
|
ynh_replace_string --match_string="$domain$path" --replace_string="__DOMAIN__PATH__" --target_file="$file"
|
|
done
|
|
|
|
find "$final_path/live/public/extensions/src/" -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' dir
|
|
do
|
|
ynh_secure_remove --file="$dir"
|
|
done
|
|
|
|
# Update the config of the app
|
|
ynh_app_setting_set --app=$app --key=install_extensions --value="0"
|
|
|
|
#=================================================
|
|
# RESTART Systemd
|
|
#=================================================
|
|
ynh_script_progression --message="Restarting $app ..."
|
|
|
|
ynh_systemd_action --service_name=$app --action=restart
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|