From edc3c1203ead3388514a11917c9b212372bc688f Mon Sep 17 00:00:00 2001 From: DDATAA <45762540+Ddataa@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:29:29 +0100 Subject: [PATCH] Update upgrade --- scripts/upgrade | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index c5453b3..6f47464 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -102,6 +102,16 @@ fi #================================================= chgrp -R www-data $final_path +#================================================= +# CREATE A SANDBOX DOMAIN +#================================================= +sandboxdomain=sandbox-$domain +# We don't test that in CI +if ! [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + yunohost domain add $sandboxdomain + yunohost domain config set $sandboxdomain -a "mail_in=0&mail_out=0" +fi + #================================================= # NGINX CONFIGURATION #================================================= @@ -154,6 +164,34 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="server available" +#================================================= +# COPY NGINX CONF IN SANDBOX DOMAIN +#================================================= +# We don't test that in CI +if ! [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + ynh_add_config --template="/etc/nginx/conf.d/$domain.d/cryptpad.conf" --destination="/etc/nginx/conf.d/$sandboxdomain.d/cryptpad.conf" +fi + +# We authorize access to sandbox domain +# We don't test that in CI +if ! [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + ynh_permission_url --permission="main" --add_url=$sandboxdomain --auth_header=true + # there is a bug in core that add a slash at the end of domain in ssowat conf for uris var + # so we use ${sandboxdomain%/} to remove the eccessive trailing slash # it doesnt work + # we use jq to correct /etc/ssowat/conf.json + uri1=$domain + uri2=$sandboxdomain + app=$app + + #we delete the uris from cryptpad.main + cat /etc/ssowat/conf.json | jq 'del(.permissions[] | select(.label=="$app") | .uris)' + #we write them again + cat /etc/ssowat/conf.json | jq --arg uri1 "$uri1" '(.permissions[] | select(.label=="$app") | .uris[0]) |=$uri1' + cat /etc/ssowat/conf.json | jq --arg uri2 "$uri2" '(.permissions[] | select(.label=="$app") | .uris[1]) |=$uri2' > /etc/ssowat/tmp.conf.json + rm /etc/ssowat/conf.json + mv /etc/ssowat/tmp.conf.json /etc/ssowat/conf.json +fi + #================================================= # RELOAD NGINX #=================================================