1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/funkwhale_ynh.git synced 2024-09-03 18:36:24 +02:00

move nginx changes in a functions to fix upgrade

This commit is contained in:
Jean-Baptiste Holcroft 2019-02-17 08:06:04 +01:00
parent 4877960ae1
commit 8ca5fb911d
5 changed files with 54 additions and 36 deletions

View file

@ -1,5 +1,40 @@
#!/bin/bash #!/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 # Redis HELPERS

View file

@ -110,15 +110,8 @@ ynh_setup_source "$final_path/code" "app-frontend"
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
# add proxy_cache and connection_upgrade at the beginning of the domain configuration # add funkwhale specifics at the beginning of the domain configuration
echo " funkwhale_nginx_domain_configure
# 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"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config

View file

@ -95,15 +95,11 @@ ynh_secure_remove "/var/log/$app"
#================================================= #=================================================
# remove domain specific configuration # remove domain specific configuration
tail -n +9 "/etc/nginx/conf.d/$domain.conf" > "/etc/nginx/conf.d/$domain.conf.temp" funkwhale_nginx_domain_cleaning
mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
# remove local nginx cache
ynh_secure_remove "/tmp/$app-transcode"
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================

View file

@ -115,18 +115,11 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name"
# Restore permissions on app files # Restore permissions on app files
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
chmod -R 755 "$final_path/code/front/dist/"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app": "/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 # RESTORE SYSTEMD
#================================================= #=================================================
@ -141,6 +134,14 @@ systemctl enable "$app-server.service"
systemctl enable "$app-worker.service" systemctl enable "$app-worker.service"
systemctl restart "$app.target" 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 # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -111,22 +111,11 @@ ynh_setup_source "$final_path/code" "app-frontend"
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
# change the global configuration
# remove domain specific configuration # remove domain specific configuration
tail -n +11 "/etc/nginx/conf.d/$domain.conf" > "/etc/nginx/conf.d/$domain.conf.temp" funkwhale_nginx_domain_cleaning
mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf"
# add proxy_cache and connection_upgrade at the beginning of the domain configuration # add funkwhale specifics at the beginning of the domain configuration
echo " funkwhale_nginx_domain_configure
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"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_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 # https://docs.funkwhale.audio/upgrading/0.17.html#upgrade-instructions
python api/manage.py script migrate_to_user_libraries --no-input 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
) )
#================================================= #=================================================