mirror of
https://github.com/YunoHost-Apps/reverseproxy_ynh.git
synced 2024-09-03 20:16:23 +02:00
c7b5b3dbee
Yunohost templating doesn't like @__NAME____proxy because `reverseproxy__2__proxy` will evaluate __2__ to $2 or @__NAME__@proxy because ynh_replace_vars uses @ as sed delimiter and ynh_replace_vars really hates multiline blocks... Using actual newlines in string produces a sed unclosed delimiter error, while using \n gets them double escaped to some weird output that crashed nginx.
66 lines
1.9 KiB
Bash
66 lines
1.9 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
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
#=================================================
|
|
# REVERSEPROXY_YNH
|
|
#=================================================
|
|
|
|
# Check domain/path availability
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
# Validate reverse proxy destination
|
|
rp_validate_proxy_path
|
|
|
|
# Validate assets_path
|
|
rp_validate_assets_path
|
|
|
|
# Special case for "/" path_url
|
|
rp_handle_webroot
|
|
|
|
# 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
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
ynh_add_nginx_config
|
|
|
|
# Make app public if necessary (yunohost setting boolean is 1 when true)
|
|
ynh_script_progression --message="Configuring permissions..." --weight=2
|
|
if [ $is_public -eq 1 ]; then
|
|
ynh_permission_update --permission="main" --add="visitors"
|
|
fi
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|