Fix linter warnings

This commit is contained in:
ericgaspar 2021-01-23 15:21:17 +01:00
parent a3e72e8412
commit 346fb7fa57
No known key found for this signature in database
GPG key ID: 574F281483054D44
8 changed files with 86 additions and 27 deletions

View file

@ -1,8 +1,11 @@
# Redirect App
# Redirect App for Yunohost
[![Integration level](https://dash.yunohost.org/integration/redirect.svg)](https://dash.yunohost.org/appci/app/redirect) ![](https://ci-apps.yunohost.org/ci/badges/redirect.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/redirect.maintain.svg)
[![Install Redirect with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=redirect)
**Add a link on your user panel redirecting to another page or app, which can be protected behind your panel for some**.
It could be an invisible redirect, an external link, another app on your local network, a reverse proxy to an app or a Docker container... Some apps can be even be protected behind your panel (meaning that you will have to log-in to access them). The only limit is your imagination - and Nginx ;).
It could be an invisible redirect, an external link, another app on your local network, a reverse proxy to an app or a Docker container... Some apps can be even be protected behind your panel (meaning that you will have to log-in to access them). The only limit is your imagination - and NGINX ;).
This app only adds a Nginx configuration file with `redirect` or `proxy_pass` rule, and a YunoHost tile. Nothing more.
@ -10,20 +13,18 @@ This app only adds a Nginx configuration file with `redirect` or `proxy_pass` ru
### Visible redirect
Visitor's address bar will change. Helpfull to add a user link to another
website
Visitor's address bar will change. Helpfull to add a user link to another website
you-domain.com -> another-domain.net
you-domain.com/foo -> another-domain.net/bar
### Invisible (proxy) redirect
Visitor's address bar will remain the same. Mostly use to serve local webserver
for a personnal application.
Visitor's address bar will remain the same. Mostly use to serve local webserver for a personnal application.
you-domain.com/foo -> http://172.0.0.1:8080/app
**IMPORTANT:** the redirect.conf file might need to be updated according to your situation!
**IMPORTANT:** the `redirect.conf` file might need to be updated according to your situation!
**WARNING:** Many apps do not support being redirected to a different path due to relative links! This means that some apps being hosted for example on http://127.0.0.1:5050/app/ HAVE TO be redirected to http://domain.tld/app/ and NOT http://domain.tld/someotherapp/

View file

@ -19,7 +19,6 @@
upgrade=1
backup_restore=1
multi_instance=1
incorrect_path=0
port_already_use=0
change_url=0
;;; Options

View file

@ -2,19 +2,19 @@
"name": "Redirect",
"id": "redirect",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 3.8"
},
"description": {
"en": "Create a redirection or a proxy to another path.",
"fr": "Créer une redirection ou un proxy vers un autre emplacement"
},
"version": "1.0.0~ynh4",
"version": "1.0.0~ynh5",
"license": "AGPL-3.0-or-later",
"url": "https://github.com/YunoHost-Apps/redirect_ynh",
"maintainer": {
"name": "alexAubin",
"email": "alex.aubin@mailoo.org"
},
"requirements": {
"yunohost": ">= 3.8.1"
},
"multi_instance": true,
"services": [
@ -53,6 +53,7 @@
},
{
"name": "redirect_type",
"type": "string",
"ask": {
"en": "Redirect type",
"fr": "Type de redirection"

View file

@ -18,10 +18,21 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
# Copy the conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -27,19 +27,20 @@ redirect_type=$YNH_APP_ARG_REDIRECT_TYPE
redirect_path=$YNH_APP_ARG_REDIRECT_PATH
# Check domain/path availability
ynh_webpath_register $app $domain $path_url
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
# Validate redirect path
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
# Save extra settings
ynh_app_setting_set $app redirect_type "$redirect_type"
ynh_app_setting_set $app redirect_path "$redirect_path"
ynh_app_setting_set --app=$app --key=redirect_type --value=$redirect_type
ynh_app_setting_set --app=$app --key=redirect_path --value=$redirect_path
#=================================================
# CONFIGURE NGINX
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Nginx configuration
for FILE in $(ls ../conf/nginx-*.conf)
@ -63,13 +64,24 @@ fi
#=================================================
# CONFIGURE SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=2
# Make app public if necessary
if [ "$redirect_type" != "private_proxy" ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/"
ynh_permission_update --permission="main" --add="visitors"
fi
# Reload Nginx and regenerate SSOwat conf
systemctl reload nginx
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -11,13 +11,28 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove configuration files
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
# Restart services
systemctl reload nginx
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -45,8 +45,18 @@ ynh_restore_file "$NGINX_CONF"
if [ "$redirect_type" != "private_proxy" ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/"
ynh_permission_update --permission="main" --add="visitors"
fi
# Reload Nginx and regenerate SSOwat conf
systemctl reload nginx
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -114,8 +114,18 @@ fi
if [ "$redirect_type" != "private_proxy" ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/"
ynh_permission_update --permission="main" --add="visitors"
fi
# Reload Nginx and regenerate SSOwat conf
systemctl reload nginx
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last