From c94ccd568977ea1c236d7c5e16ad21838a61c72e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 27 Jan 2022 00:53:06 +0100 Subject: [PATCH] Apply last example_ynh --- conf/nginx.conf | 69 +++++++++++++++++++++------------------------- manifest.json | 4 +-- scripts/backup | 1 - scripts/change_url | 1 + scripts/install | 24 +++++++++------- scripts/remove | 16 +++++------ scripts/restore | 2 +- scripts/upgrade | 1 + 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 0d1fe19..fde4204 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,56 +1,51 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } + proxy_pass http://localhost:__PORT__; + proxy_http_version 1.1; + client_max_body_size 31M; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forward-Proto http; + proxy_set_header X-Nginx-Proxy true; + expires epoch; + proxy_no_cache 1; + proxy_temp_file_write_size 64k; + proxy_connect_timeout 10080s; + proxy_send_timeout 10080; + proxy_read_timeout 10080; + proxy_buffer_size 64k; + proxy_buffers 16 32k; + proxy_busy_buffers_size 64k; + proxy_redirect off; + proxy_request_buffering on; + proxy_buffering on; + #proxy_cache my_cache; + #proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; - proxy_pass http://localhost:__PORT__; - proxy_http_version 1.1; - client_max_body_size 31M; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forward-Proto http; - proxy_set_header X-Nginx-Proxy true; - expires epoch; - proxy_no_cache 1; - proxy_temp_file_write_size 64k; - proxy_connect_timeout 10080s; - proxy_send_timeout 10080; - proxy_read_timeout 10080; - proxy_buffer_size 64k; - proxy_buffers 16 32k; - proxy_busy_buffers_size 64k; - proxy_redirect off; - proxy_request_buffering on; - proxy_buffering on; - #proxy_cache my_cache; - #proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; - -location ~ ^/(icons|images|media|emoji)/(.*)/(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { + location ~ ^/(icons|images|media|emoji)/(.*)/(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { expires 7d; proxy_pass http://localhost:__PORT__; - } + } -location ~ ^/icons/(.*)/(like|repeat|calendar)(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { + location ~ ^/icons/(.*)/(like|repeat|calendar)(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { expires epoch; proxy_no_cache 1; proxy_pass http://localhost:__PORT__; - } + } -location ~ ^/icons/(like|repeat|calendar)(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { + location ~ ^/icons/(like|repeat|calendar)(.*).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { expires epoch; proxy_no_cache 1; proxy_pass http://localhost:__PORT__; - } + } -location ~ ^/users/(.*)/(image|banner).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { + location ~ ^/users/(.*)/(image|banner).(png|jpg|gif|webp|mp3|ogv|ogg|mp4) { expires epoch; proxy_no_cache 1; proxy_pass http://localhost:__PORT__; - } + } } diff --git a/manifest.json b/manifest.json index 097be8b..d334fbc 100644 --- a/manifest.json +++ b/manifest.json @@ -18,14 +18,14 @@ "name": "Anmol Sharma" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" diff --git a/scripts/backup b/scripts/backup index b87ffa5..8ecf36d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script diff --git a/scripts/change_url b/scripts/change_url index f6bb280..3fb2f2f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -112,6 +112,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= diff --git a/scripts/install b/scripts/install index 5ee48eb..2fcec15 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -95,7 +94,6 @@ mkdir $public_path mkdir -p $final_path/accounts/newsmirror ln -s $final_path/accounts/newsmirror $public_path/newsmirror - chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -109,15 +107,29 @@ chown -R $app:www-data $public_path #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +# Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP +#================================================= +# ... +#================================================= +ynh_script_progression --message="Create admin user" --weight=1 + +# Create admin +python3 $final_path/epicyon.py --addaccount=$admin --password=$password --domain=$domain + #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 +# Create a dedicated systemd config ynh_add_systemd_config +#================================================= +# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -133,14 +145,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SPECIFIC SETUP -#================================================= -ynh_script_progression --message="Create admin user" --weight=1 - -# Create admin -python3 $final_path/epicyon.py --addaccount=$admin --password=$password --domain=$domain - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 3c88041..68f57cc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -42,14 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -67,6 +59,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 6bf2c97..6720c80 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -46,6 +45,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index e42ccb2..9caeea5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed)