From 346fb7fa57e7cd127f21639e47a3d0deeb1fe760 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 23 Jan 2021 15:21:17 +0100 Subject: [PATCH] Fix linter warnings --- README.md | 15 ++++++++------- check_process | 1 - manifest.json | 9 +++++---- scripts/backup | 11 +++++++++++ scripts/install | 24 ++++++++++++++++++------ scripts/remove | 21 ++++++++++++++++++--- scripts/restore | 16 +++++++++++++--- scripts/upgrade | 16 +++++++++++++--- 8 files changed, 86 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 8818b1f..8b3b9aa 100644 --- a/README.md +++ b/README.md @@ -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/ diff --git a/check_process b/check_process index 2aa8bd2..fa373d2 100644 --- a/check_process +++ b/check_process @@ -19,7 +19,6 @@ upgrade=1 backup_restore=1 multi_instance=1 - incorrect_path=0 port_already_use=0 change_url=0 ;;; Options diff --git a/manifest.json b/manifest.json index c345323..7a1f148 100644 --- a/manifest.json +++ b/manifest.json @@ -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" diff --git a/scripts/backup b/scripts/backup index 8aa1ce6..cc3bbed 100644 --- a/scripts/backup +++ b/scripts/backup @@ -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)." diff --git a/scripts/install b/scripts/install index 8d3f55e..66b72c6 100644 --- a/scripts/install +++ b/scripts/install @@ -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 diff --git a/scripts/remove b/scripts/remove index 82109e4..304eab7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/restore b/scripts/restore index 0ec55b3..5c4c3a6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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 diff --git a/scripts/upgrade b/scripts/upgrade index 280fc98..7b9df56 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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