mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
Fix: restore, remove change_url scripts
This commit is contained in:
parent
36600c3835
commit
437d1c023b
4 changed files with 54 additions and 6 deletions
|
@ -15,7 +15,37 @@ pkg_dependencies=""
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Substitute/replace a string (or expression) by another in a file on a
|
||||
#
|
||||
# usage: ynh_replace_string_occurrence --occurrence=occurrence --match_string=match_string --replace_string=replace_string --target_file=target_file
|
||||
# | arg: -o, --occurrence= - Replace the nth occurrence in the file
|
||||
# | arg: -m, --match_string= - String to be searched and replaced in the file
|
||||
# | arg: -r, --replace_string= - String that will replace matches
|
||||
# | arg: -f, --target_file= - File in which the string will be replaced.
|
||||
#
|
||||
# As this helper is based on sed command, regular expressions and references to
|
||||
# sub-expressions can be used (see sed manual page for more information)
|
||||
#
|
||||
ynh_replace_string_occurrence() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=omrf
|
||||
local -A args_array=([o]=occurrence [m]=match_string= [r]=replace_string= [f]=target_file=)
|
||||
local occurrence
|
||||
local match_string
|
||||
local replace_string
|
||||
local target_file
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
set +o xtrace # set +x
|
||||
|
||||
local delimit=@
|
||||
# Escape the delimiter if it's in the string.
|
||||
match_string=${match_string//${delimit}/"\\${delimit}"}
|
||||
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
||||
|
||||
set -o xtrace # set -x
|
||||
sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}${occurrence}" "$target_file"
|
||||
}
|
||||
|
||||
#================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
|
|
|
@ -36,6 +36,8 @@ port_files=$(ynh_app_setting_get --app=$app --key=port_files)
|
|||
port_syncing_server=$(ynh_app_setting_get --app=$app --key=port_syncing_server)
|
||||
port_syncing_server_worker=$(ynh_app_setting_get --app=$app --key=port_syncing_server_worker)
|
||||
|
||||
config_api_gateway="$final_path/live/api-gateway.env"
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -104,6 +106,13 @@ fi
|
|||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modify configuring..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="^FILES_SERVER_URL.*$" --replace_string="FILES_SERVER_URL=https://$new_domain$new_path/files" --target_file="$config_api_gateway"
|
||||
ynh_store_file_checksum --file="$config_api_gateway"
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
|
|
|
@ -153,6 +153,12 @@ ynh_remove_fail2ban_config
|
|||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE CRON CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing cron configuration..." --weight=1
|
||||
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE SWAP
|
||||
#=================================================
|
||||
|
|
|
@ -47,6 +47,7 @@ config_auth_worker="$final_path/live/auth-worker.env"
|
|||
config_files="$final_path/live/files.env"
|
||||
config_syncing_server="$final_path/live/syncing-server.env"
|
||||
config_syncing_server_worker="$final_path/live/syncing-server-worker.env"
|
||||
config_nginx="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -165,22 +166,24 @@ ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=re
|
|||
ynh_replace_string --match_string="^REDIS_URL.*$" --replace_string="REDIS_URL=redis://localhost:6379/$redis_db" --target_file="$config_syncing_server_worker"
|
||||
# Syncing_Server Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server" --target_file="$config_syncing_server"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_api_gateway"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_auth"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=$port_syncing_server" --target_file="$config_auth_worker"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_JS_URL.*$" --replace_string="SYNCING_SERVER_JS_URL=http://localhost:$port_syncing_server" --target_file="$config_api_gateway"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=http://localhost:$port_syncing_server" --target_file="$config_auth"
|
||||
ynh_replace_string --match_string="^SYNCING_SERVER_URL.*$" --replace_string="SYNCING_SERVER_URL=http://localhost:$port_syncing_server" --target_file="$config_auth_worker"
|
||||
# Syncing_Server_Worker Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_syncing_server_worker" --target_file="$config_syncing_server_worker"
|
||||
# Auth Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth" --target_file="$config_auth"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_api_gateway"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=$port_auth" --target_file="$config_syncing_server_worker"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=http://localhost:$port_auth" --target_file="$config_api_gateway"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=http://localhost:$port_auth" --target_file="$config_syncing_server"
|
||||
ynh_replace_string --match_string="^AUTH_SERVER_URL.*$" --replace_string="AUTH_SERVER_URL=http://localhost:$port_auth" --target_file="$config_syncing_server_worker"
|
||||
# Auth_Worker Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_auth_worker" --target_file="$config_auth_worker"
|
||||
# API-Gateway Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_api_gateway" --target_file="$config_api_gateway"
|
||||
ynh_replace_string_occurrence --occurrence="1" --match_string="^proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_api_gateway/;" --target_file="$config_nginx"
|
||||
# Files Port
|
||||
ynh_replace_string --match_string="^PORT.*$" --replace_string="PORT=$port_files" --target_file="$config_files"
|
||||
ynh_replace_string_occurrence --occurrence="2" --match_string="^proxy_pass.*$" --replace_string="proxy_pass http://127.0.0.1:$port_files/;" --target_file="$config_nginx"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
|
Loading…
Reference in a new issue