From bceae5e35b22706cb8afc700c05f8afdb828f30e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Jun 2020 00:45:02 +0200 Subject: [PATCH] Apply last example_ynh --- check_process | 12 +----------- conf/nginx.conf | 24 ++++++++++++++++-------- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 33 ++++++++++++++++----------------- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/check_process b/check_process index a7a503d..bb75880 100644 --- a/check_process +++ b/check_process @@ -24,18 +24,8 @@ port_already_use=0 change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=0 -# Level 5: + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index 693515a..1fdf0f5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,18 @@ - +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $http_host; - proxy_pass http://127.0.0.1:__PORT__; - client_max_body_size 100M; - } + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $http_host; + proxy_pass http://127.0.0.1:__PORT__; + client_max_body_size 100M; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/scripts/remove b/scripts/remove index 7a4734d..6b68a77 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi diff --git a/scripts/restore b/scripts/restore index b631be9..b8fb7a5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -81,7 +81,7 @@ chown -R $app: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=7 +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index 2079697..1791b57 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,15 +53,14 @@ if [ -z "$db_name" ]; then ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi - #================================================= # CLOSE A PORT #================================================= if yunohost firewall list | grep -q "\- $port$" then - echo "Close port $port" - yunohost firewall disallow TCP $port 2>&1 + ynh_script_progression --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $port fi #================================================= @@ -207,6 +206,20 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app daemon for Ghost" --log_type "systemd" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ghost boot" + #================================================= # SETUP SSOWAT #================================================= @@ -222,20 +235,6 @@ then ynh_app_setting_set --app=$app --key=skipped_uris --value="/" fi -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description "$app daemon for Ghost" --log_type "systemd" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ghost boot" - #================================================= # RELOAD NGINX #=================================================