From 8ca5fb911d4b769893fab264ee53d4dab57a92a0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sun, 17 Feb 2019 08:06:04 +0100 Subject: [PATCH] move nginx changes in a functions to fix upgrade --- scripts/_common.sh | 35 +++++++++++++++++++++++++++++++++++ scripts/install | 11 ++--------- scripts/remove | 6 +----- scripts/restore | 17 +++++++++-------- scripts/upgrade | 21 +++++++-------------- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b5d7203..f491c5c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,40 @@ #!/bin/bash +# funkwhale needs edits to the domain config file +# this function removes funkwhale specifics +funkwhale_nginx_domain_cleaning() { + local line + local tempFile + local nginxConf + + nginxConf="/etc/nginx/conf.d/$domain.conf" + tempFile="$nginxConf.temp" + + line=$(sed -n '/server /=' "$nginxConf" | head -n 1) + + tail -n +"$line" "$nginxConf" > "$tempFile" + mv "$tempFile" "$nginxConf" +} + +# funkwhale needs edits to the domain config file +# this function adds funkwhale specifics +funkwhale_nginx_domain_configure() { + local tempFile + local nginxConf + + nginxConf="/etc/nginx/conf.d/$domain.conf" + tempFile="$nginxConf.temp" + + echo " +# required for websocket support +map \$http_upgrade \$connection_upgrade { + default upgrade; + '' close; +} +" | cat - "$nginxConf" > "$tempFile" + mv "$tempFile" "$nginxConf" +} + #================================================= # # Redis HELPERS diff --git a/scripts/install b/scripts/install index 25cedc3..aeb9b20 100644 --- a/scripts/install +++ b/scripts/install @@ -110,15 +110,8 @@ ynh_setup_source "$final_path/code" "app-frontend" # NGINX CONFIGURATION #================================================= -# add proxy_cache and connection_upgrade at the beginning of the domain configuration -echo " - -# required for websocket support -map \$http_upgrade \$connection_upgrade { - default upgrade; - '' close; -} -" | cat - "/etc/nginx/conf.d/$domain.conf" > temp && mv temp "/etc/nginx/conf.d/$domain.conf" +# add funkwhale specifics at the beginning of the domain configuration +funkwhale_nginx_domain_configure # Create a dedicated nginx config ynh_add_nginx_config diff --git a/scripts/remove b/scripts/remove index 6cd7808..f136b49 100644 --- a/scripts/remove +++ b/scripts/remove @@ -95,15 +95,11 @@ ynh_secure_remove "/var/log/$app" #================================================= # remove domain specific configuration -tail -n +9 "/etc/nginx/conf.d/$domain.conf" > "/etc/nginx/conf.d/$domain.conf.temp" -mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf" +funkwhale_nginx_domain_cleaning # Remove the dedicated nginx config ynh_remove_nginx_config -# remove local nginx cache -ynh_secure_remove "/tmp/$app-transcode" - #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/restore b/scripts/restore index 12ccaae..9e46eaa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -115,18 +115,11 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name" # Restore permissions on app files chown -R "$app": "$final_path" +chmod -R 755 "$final_path/code/front/dist/" mkdir -p "/var/log/$app" chown -R "$app": "/var/log/$app" -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add "$app-server" --log "/var/log/$app/server.log" -yunohost service add "$app-worker" --log "/var/log/$app/worker.log" -yunohost service add "$app-beat" --log "/var/log/$app/beat.log" - #================================================= # RESTORE SYSTEMD #================================================= @@ -141,6 +134,14 @@ systemctl enable "$app-server.service" systemctl enable "$app-worker.service" systemctl restart "$app.target" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "$app-server" --log "/var/log/$app/server.log" +yunohost service add "$app-worker" --log "/var/log/$app/worker.log" +yunohost service add "$app-beat" --log "/var/log/$app/beat.log" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 68c2ce5..e86f1de 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,22 +111,11 @@ ynh_setup_source "$final_path/code" "app-frontend" # NGINX CONFIGURATION #================================================= -# change the global configuration # remove domain specific configuration -tail -n +11 "/etc/nginx/conf.d/$domain.conf" > "/etc/nginx/conf.d/$domain.conf.temp" -mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf" +funkwhale_nginx_domain_cleaning -# add proxy_cache and connection_upgrade at the beginning of the domain configuration -echo " - -proxy_cache_path /tmp/$app-transcode levels=1:2 keys_zone=$app-transcode:10m max_size=1g inactive=7d; - -# required for websocket support -map \$http_upgrade \$connection_upgrade { - default upgrade; - '' close; -} -" | cat - "/etc/nginx/conf.d/$domain.conf" > temp && mv temp "/etc/nginx/conf.d/$domain.conf" +# add funkwhale specifics at the beginning of the domain configuration +funkwhale_nginx_domain_configure # Create a dedicated nginx config ynh_add_nginx_config @@ -226,6 +215,10 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile" # https://docs.funkwhale.audio/upgrading/0.17.html#upgrade-instructions python api/manage.py script migrate_to_user_libraries --no-input + + # Delete pre 0.17 federated tracks [manual action suggested] + # https://dev.funkwhale.audio/funkwhale/funkwhale/tags/0.18 + python api/manage.py script delete_pre_017_federated_uploads --no-input ) #=================================================