reverseproxy_ynh/scripts/install
2023-01-08 14:33:31 +01:00

62 lines
1.8 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
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 FROM THE MANIFEST
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
proxy_path=$YNH_APP_ARG_PROXY_PATH
assets_path=$YNH_APP_ARG_ASSETS_PATH
[[ "$assets_path" = "" ]] && assets_path="/dev/null"
is_public=$YNH_APP_ARG_IS_PUBLIC
#=================================================
# REVERSE PROXY LOGIC
#=================================================
# Check domain/path availability
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
# Validate reverse proxy destination
rp_validate_proxy_path "$proxy_path"
# Save extra settings
ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path
ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path
# Configure nginx
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
rp_make_webconfig
# Make app public if necessary
ynh_script_progression --message="Configuring permissions..." --weight=2
rp_make_permissions $is_public
# Reload nginx
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
rp_reload_web
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last