From a1b3a034c729d557e3e2d601000a74abbbcdbdf7 Mon Sep 17 00:00:00 2001 From: Evilham Date: Thu, 10 Mar 2022 21:28:28 +0100 Subject: [PATCH] [__jitsi_meet_domain] Support the --state parameter This enables removing domains in a simple fashion. Closes #3. --- type/__jitsi_meet_domain/man.rst | 4 +++ type/__jitsi_meet_domain/manifest | 30 +++++++++++++++++-- .../parameter/default/state | 1 + type/__jitsi_meet_domain/parameter/optional | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 type/__jitsi_meet_domain/parameter/default/state diff --git a/type/__jitsi_meet_domain/man.rst b/type/__jitsi_meet_domain/man.rst index ff78287..b035555 100644 --- a/type/__jitsi_meet_domain/man.rst +++ b/type/__jitsi_meet_domain/man.rst @@ -60,6 +60,10 @@ start-video-muted Defaults to 10. +state + Whether the domain is 'present' or 'absent', defaults to 'present'. + + turn-server The TURN server to be used. Defaults to `__target_host`. diff --git a/type/__jitsi_meet_domain/manifest b/type/__jitsi_meet_domain/manifest index 5c92c1c..87af1b9 100755 --- a/type/__jitsi_meet_domain/manifest +++ b/type/__jitsi_meet_domain/manifest @@ -21,6 +21,7 @@ VIDEO_CONSTRAINTS="$(cat "${__object}/parameter/video-constraints")" BRANDING_INDEX="$(cat "${__object}/parameter/branding-index")" BRANDING_JSON="$(cat "${__object}/parameter/branding-json")" BRANDING_WATERMARK="$(cat "${__object}/parameter/branding-watermark")" +STATE="$(cat "${__object}/parameter/state")" if [ "${BRANDING_INDEX}" = "-" ]; then BRANDING_INDEX="${__object}/stdin" @@ -47,11 +48,31 @@ if [ -n "${BRANDING_JSON}" ]; then DYNAMIC_BRANDING_URL="/branding.json" fi +case "${STATE}" in + present) + # When adding the domain, Let's Encrypt must come before nginx + le_require="" + nginx_require="__letsencrypt_cert/${DOMAIN}" + ;; + absent) + # When removing, nginx must come before Let's Encrypt + le_require="__file/etc/nginx/sites-enabled/${DOMAIN}.conf" + nginx_require="" + ;; + *) + cat >> /dev/stderr <<-EOM + Unsupported state '${STATE}', must be 'present' or 'absent'. + EOM + exit 1 + ;; +esac + # # Deal with certbot # # use object id as domain -__letsencrypt_cert "${DOMAIN}" \ +require="${le_require}" __letsencrypt_cert "${DOMAIN}" \ + --state "${STATE}" \ --admin-email "${ADMIN_EMAIL}" \ --deploy-hook "service nginx reload" \ --webroot /usr/share/jitsi-meet @@ -59,8 +80,9 @@ __letsencrypt_cert "${DOMAIN}" \ # Create virtualhost for nginx # shellcheck source=type/__jitsi_meet_domain/files/nginx.sh . "${__type}/files/nginx.sh" # This defines JITSI_NGINX_CONFIG -require="__letsencrypt_cert/${DOMAIN}" __file \ +require="${nginx_require}" __file \ "/etc/nginx/sites-enabled/${DOMAIN}.conf" \ + --state "${STATE}" \ --mode 0644 --source "-" <