Use ynh_script_progression in _common.sh script

This commit is contained in:
selfhoster1312 2023-01-08 14:46:10 +01:00
parent fea7706579
commit bc55b0d0ff
6 changed files with 11 additions and 15 deletions

View file

@ -28,7 +28,7 @@ rp_validate_proxy_path() {
# Make reverse proxy public if $1 is 1 # Make reverse proxy public if $1 is 1
# Yunohost boolean params are 1 if true # Yunohost boolean params are 1 if true
rp_make_permissions() { rp_make_permissions() {
#ynh_script_progression --message="Configuring permissions..." --weight=2 ynh_script_progression --message="Configuring permissions..." --weight=2
if [ $1 = 1 ]; then if [ $1 = 1 ]; then
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
@ -37,7 +37,7 @@ rp_make_permissions() {
# (re)generate nginx config # (re)generate nginx config
rp_make_webconfig() { rp_make_webconfig() {
#ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Nginx configuration # Nginx configuration
ynh_replace_string "YNH_LOCATION" "$path_url" ../conf/nginx.conf ynh_replace_string "YNH_LOCATION" "$path_url" ../conf/nginx.conf
@ -48,6 +48,6 @@ rp_make_webconfig() {
} }
rp_reload_web() { rp_reload_web() {
#ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
} }

View file

@ -29,9 +29,8 @@ new_path=$YNH_APP_NEW_PATH
# Path availability is already checked for # Path availability is already checked for
#================================================= #=================================================
# CONFIGURE NGINX # REVERSEPROXY_YNH
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Nginx configuration # Nginx configuration
ynh_replace_string "$old_path {" "$new_path {" /etc/nginx/conf.d/$old_domain.d/$app.conf ynh_replace_string "$old_path {" "$new_path {" /etc/nginx/conf.d/$old_domain.d/$app.conf
@ -42,7 +41,6 @@ ynh_replace_string "302 ${old_path}/" "302 ${new_path}/" /etc/nginx/conf.d/$old_
[[ "$old_domain" != "$new_domain" ]] && mv /etc/nginx/conf.d/$old_domain.d/$app.conf /etc/nginx/conf.d/$new_domain.d/$app.conf [[ "$old_domain" != "$new_domain" ]] && mv /etc/nginx/conf.d/$old_domain.d/$app.conf /etc/nginx/conf.d/$new_domain.d/$app.conf
# Reload nginx # Reload nginx
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
rp_reload_web rp_reload_web
#================================================= #=================================================

View file

@ -30,7 +30,7 @@ assets_path=$YNH_APP_ARG_ASSETS_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
#================================================= #=================================================
# REVERSE PROXY LOGIC # REVERSEPROXY_YNH
#================================================= #=================================================
# Check domain/path availability # Check domain/path availability
@ -44,15 +44,12 @@ ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path
ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path
# Configure nginx # Configure nginx
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
rp_make_webconfig rp_make_webconfig
# Make app public if necessary # Make app public if necessary
ynh_script_progression --message="Configuring permissions..." --weight=2
rp_make_permissions $is_public rp_make_permissions $is_public
# Reload nginx # Reload nginx
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
rp_reload_web rp_reload_web
#================================================= #=================================================

View file

@ -19,14 +19,13 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REVERSEPROXY_YNH
#================================================= #=================================================
# Remove configuration files # Remove configuration files
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
# Reload nginx # Reload nginx
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
rp_reload_web rp_reload_web
#================================================= #=================================================

View file

@ -27,6 +27,10 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path)
assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) assets_path=$(ynh_app_setting_get --app=$app --key=assets_path)
#=================================================
# REVERSEPROXY_YNH
#=================================================
# Revalidate destination path # Revalidate destination path
rp_validate_proxy_path "$proxy_path" rp_validate_proxy_path "$proxy_path"

View file

@ -35,18 +35,16 @@ ynh_clean_setup () {
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# REVERSE PROXY LOGIC # REVERSEPROXY_YNH
#================================================= #=================================================
# Validate proxy destination # Validate proxy destination
rp_validate_proxy_path "$proxy_path" rp_validate_proxy_path "$proxy_path"
# Configure nginx # Configure nginx
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
rp_make_webconfig rp_make_webconfig
# Reload nginx # Reload nginx
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
rp_reload_web rp_reload_web
#================================================= #=================================================