diff --git a/scripts/upgrade b/scripts/upgrade index 4ef359f..fb98cca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,3 +1,4 @@ + #!/bin/bash #================================================= @@ -107,26 +108,19 @@ then chown -R $app:$app $final_path chmod 755 $final_path - # Create the visitors permission if needed - visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo 0 || echo 1) - if [[ $visitors_enabled -eq 1 ]]; then + # Temporarily enable visitors for curl if needed + visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no) + if [[ $visitors_enabled == "no" ]]; then ynh_permission_update --permission "main" --add "visitors" - ynh_systemd_action --service_name=nginx --action=reload - # Finalize the upgrade - ynh_local_curl "/index.php" - sleep 5 - ynh_local_curl "/index.php" - upgrade_type="UPGRADE_APP" - ynh_permission_update --permission "main" --remove "visitors" fi - if [[ $visitors_enabled -eq 0 ]]; then - ynh_systemd_action --service_name=nginx --action=reload - # Finalize the upgrade - ynh_local_curl "/index.php" - sleep 5 - ynh_local_curl "/index.php" - upgrade_type="UPGRADE_APP" + # Finalize the upgrade + ynh_local_curl "/index.php" + sleep 5 + ynh_local_curl "/index.php" + + if [[ $visitors_enabled == "no" ]]; then + ynh_permission_update --permission "main" --remove "visitors" fi fi #================================================= @@ -161,26 +155,19 @@ then chown -R $app:$app $final_path chmod 755 $final_path - # Create the visitors permission if needed - visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo 0 || echo 1) - if [[ $visitors_enabled -eq 1 ]]; then + # Temporarily enable visitors for curl if needed + visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no) + if [[ $visitors_enabled == "no" ]]; then ynh_permission_update --permission "main" --add "visitors" - ynh_systemd_action --service_name=nginx --action=reload - # Finalize the upgrade - ynh_local_curl "/index.php" - sleep 5 - ynh_local_curl "/index.php" - upgrade_type="UPGRADE_APP" - ynh_permission_update --permission "main" --remove "visitors" fi - if [[ $visitors_enabled -eq 0 ]]; then - ynh_systemd_action --service_name=nginx --action=reload - # Finalize the upgrade - ynh_local_curl "/index.php" - sleep 5 - ynh_local_curl "/index.php" - upgrade_type="UPGRADE_APP" + # Finalize the upgrade + ynh_local_curl "/index.php" + sleep 5 + ynh_local_curl "/index.php" + + if [[ $visitors_enabled == "no" ]]; then + ynh_permission_update --permission "main" --remove "visitors" fi fi