YunoHost-Apps / opensondage_ynh

OpenSondage for YunoHost
https://framadate.org/
GNU Affero General Public License v3.0
16 stars 14 forks source link

Failed to change url of the app #74

Closed eauchat closed 2 years ago

eauchat commented 3 years ago

Describe the bug

I was trying to change the url of this app from the webadmin from something.domain.tld/date to domain.tld/date (both domains being obviously registered in yunohost). The operation failed, here are the logs from it:

2021-05-22 13:56:41,598: DEBUG - Executing command '/bin/bash -x "./change_url"  7>&1'
2021-05-22 13:56:41,603: DEBUG - + source _common.sh
2021-05-22 13:56:41,603: DEBUG - ++ YNH_PHP_VERSION=7.3
2021-05-22 13:56:41,603: DEBUG - ++ pkg_dependencies='php7.3-mbstring php7.3-intl php7.3-xml php7.3-cli'
2021-05-22 13:56:41,603: DEBUG - + source /usr/share/yunohost/helpers
2021-05-22 13:56:41,604: DEBUG - +++ grep xtrace
2021-05-22 13:56:41,604: DEBUG - +++ set +o
2021-05-22 13:56:41,605: DEBUG - ++ readonly 'XTRACE_ENABLE=set -o xtrace'
2021-05-22 13:56:41,605: DEBUG - ++ XTRACE_ENABLE='set -o xtrace'
2021-05-22 13:56:41,621: DEBUG - + ynh_abort_if_errors
2021-05-22 13:56:41,621: DEBUG - + set -o errexit
2021-05-22 13:56:41,621: DEBUG - + set -o nounset
2021-05-22 13:56:41,621: DEBUG - + trap ynh_exit_properly EXIT
2021-05-22 13:56:41,621: DEBUG - + old_domain=something.domain.tld
2021-05-22 13:56:41,622: DEBUG - + old_path=/date
2021-05-22 13:56:41,622: DEBUG - + new_domain=domain.tld
2021-05-22 13:56:41,622: DEBUG - + new_path=/date
2021-05-22 13:56:41,622: DEBUG - + app=opensondage
2021-05-22 13:56:41,662: DEBUG - + echo '[++..................] > Loading installation settings...'
2021-05-22 13:56:41,662: INFO - [++..................] > Loading installation settings...
2021-05-22 13:56:41,665: DEBUG - ++ ynh_app_setting_get --app=opensondage --key=final_path
2021-05-22 13:56:41,686: DEBUG - ++ [[ final_path =~ (unprotected|protected|skipped)_ ]]
2021-05-22 13:56:41,686: DEBUG - ++ ynh_app_setting get opensondage final_path
2021-05-22 13:56:41,721: DEBUG - + final_path=/var/www/opensondage
2021-05-22 13:56:41,721: DEBUG - ++ ynh_app_setting_get --app=opensondage --key=is_public
2021-05-22 13:56:41,743: DEBUG - ++ [[ is_public =~ (unprotected|protected|skipped)_ ]]
2021-05-22 13:56:41,743: DEBUG - ++ ynh_app_setting get opensondage is_public
2021-05-22 13:56:41,774: DEBUG - + is_public=1
2021-05-22 13:56:41,774: DEBUG - + change_domain=0
2021-05-22 13:56:41,774: DEBUG - + '[' something.domain.tld '!=' domain.tld ']'
2021-05-22 13:56:41,774: DEBUG - + change_domain=1
2021-05-22 13:56:41,774: DEBUG - + change_path=0
2021-05-22 13:56:41,774: DEBUG - + '[' /date '!=' /date ']'
2021-05-22 13:56:41,837: DEBUG - + echo '[##++++++............] > Updating NGINX web server configuration...'
2021-05-22 13:56:41,837: DEBUG - + nginx_conf_path=/etc/nginx/conf.d/something.domain.tld.d/opensondage.conf
2021-05-22 13:56:41,837: DEBUG - + '[' 0 -eq 1 ']'
2021-05-22 13:56:41,837: DEBUG - + '[' 1 -eq 1 ']'
2021-05-22 13:56:41,837: DEBUG - + ynh_delete_file_checksum --file=/etc/nginx/conf.d/something.domain.tld.d/opensondage.conf
2021-05-22 13:56:41,838: INFO - [##++++++............] > Updating NGINX web server configuration...
2021-05-22 13:56:41,838: DEBUG - + local checksum_setting_name=checksum__etc_nginx_conf.d_something.domain.tld.d_opensondage.conf
2021-05-22 13:56:41,838: DEBUG - + ynh_app_setting_delete --app=opensondage --key=checksum__etc_nginx_conf.d_something.domain.tld.d_opensondage.conf
2021-05-22 13:56:41,846: DEBUG - + [[ checksum__etc_nginx_conf.d_something.domain.tld.d_opensondage.conf =~ (unprotected|skipped|protected)_ ]]
2021-05-22 13:56:41,846: DEBUG - + ynh_app_setting delete opensondage checksum__etc_nginx_conf.d_something.domain.tld.d_opensondage.conf
2021-05-22 13:56:41,879: DEBUG - + mv /etc/nginx/conf.d/something.domain.tld.d/opensondage.conf /etc/nginx/conf.d/domain.tld.d/opensondage.conf
2021-05-22 13:56:41,880: DEBUG - + ynh_store_file_checksum --file=/etc/nginx/conf.d/domain.tld.d/opensondage.conf
2021-05-22 13:56:41,889: DEBUG - + local checksum_setting_name=checksum__etc_nginx_conf.d_domain.tld.d_opensondage.conf
2021-05-22 13:56:41,890: DEBUG - ++ cut '--delimiter= ' --fields=1
2021-05-22 13:56:41,890: DEBUG - ++ md5sum /etc/nginx/conf.d/domain.tld.d/opensondage.conf
2021-05-22 13:56:41,892: DEBUG - + ynh_app_setting_set --app=opensondage --key=checksum__etc_nginx_conf.d_domain.tld.d_opensondage.conf --value=6d52956c25c79b82f6dcaabd38b0e09a
2021-05-22 13:56:41,934: DEBUG - + [[ checksum__etc_nginx_conf.d_domain.tld.d_opensondage.conf =~ (unprotected|protected|skipped)_ ]]
2021-05-22 13:56:41,934: DEBUG - + ynh_app_setting set opensondage checksum__etc_nginx_conf.d_domain.tld.d_opensondage.conf 6d52956c25c79b82f6dcaabd38b0e09a
2021-05-22 13:56:41,966: DEBUG - + '[' -n '' ']'
2021-05-22 13:56:41,966: DEBUG - + unset backup_file_checksum
2021-05-22 13:56:41,996: DEBUG - + echo '[########+++.........] > Reconfiguring OpenSondage...'
2021-05-22 13:56:41,996: DEBUG - + ynh_replace_string '--match_string=const APP_URL = '\''something.domain.tld'\'';' '--replace_string=const APP_URL = '\''domain.tld'\'';' --target_file=/var/www/opensondage/app/inc/config.php
2021-05-22 13:56:41,997: INFO - [########+++.........] > Reconfiguring OpenSondage...
2021-05-22 13:56:42,041: DEBUG - + local delimit=@
2021-05-22 13:56:42,041: DEBUG - + match_string='const APP_URL = '\''something.domain.tld'\'';'
2021-05-22 13:56:42,042: DEBUG - + replace_string='const APP_URL = '\''domain.tld'\'';'
2021-05-22 13:56:42,042: DEBUG - + sed --in-place 's@const APP_URL = '\''something.domain.tld'\'';@const APP_URL = '\''domain.tld'\'';@g' /var/www/opensondage/app/inc/config.php
2021-05-22 13:56:42,131: INFO - [###########+++......] > Upgrading SSOwat configuration...
2021-05-22 13:56:42,132: DEBUG - + echo '[###########+++......] > Upgrading SSOwat configuration...'
2021-05-22 13:56:42,132: DEBUG - + '[' 1 -eq 1 ']'
2021-05-22 13:56:42,132: DEBUG - + ynh_app_setting_delete --app=opensondage --key=protected_regex
2021-05-22 13:56:42,152: DEBUG - + [[ protected_regex =~ (unprotected|skipped|protected)_ ]]
2021-05-22 13:56:42,152: DEBUG - + yunohost app setting opensondage protected_regex -d
2021-05-22 13:56:42,727: WARNING - ./change_url: line 104: path_url: unbound variable
2021-05-22 13:56:42,728: DEBUG - ++ ynh_exit_properly
2021-05-22 13:56:42,728: DEBUG - ++ local exit_code=1
2021-05-22 13:56:42,728: DEBUG - ++ rm -rf /var/cache/yunohost/download/
2021-05-22 13:56:42,728: DEBUG - ++ '[' 1 -eq 0 ']'
2021-05-22 13:56:42,728: DEBUG - ++ trap '' EXIT
2021-05-22 13:56:42,728: DEBUG - ++ set +o errexit
2021-05-22 13:56:42,728: DEBUG - ++ set +o nounset
2021-05-22 13:56:42,729: DEBUG - ++ sleep 0.5
2021-05-22 13:56:43,230: ERROR - Failed to change 'opensondage' url.

It seems the problem comes from this:

Warning: ./change_url: line 104: path_url: unbound variable

but I don't see what's problematic at line 104 to the change_url script.

From that, there are two problems, one is that the app still thinks to be registered on something.domain.tld, the second one is that I realized that the opensondage.conf nginx file has already been moved to /etc/nginx/conf.d/domain.tld.d/ so the app doesn't work anymore on it's past domain as well.

Context

Steps to reproduce

The equivalent command, which I then tried as well is: sudo yunohost app change-url opensondage -d domain.tld -p "date"

eauchat commented 3 years ago

Ok, so fiddling a bit I figured out the issue, I think it's that because I wasn't changing the path (only the domain), then the variable path_url was not set, and therefore it could not be found in lines 104 and 110 of the change_url script.

I managed to change the url changing also the path, just had to move back nginx conf by hand and correct things in /var/www/opensondage/app/inc/config.php.

Would be probably nice if the script had a way to revert it's changes when it exits on error.