[__jitsi_meet_domain] Support the --state parameter

This enables removing domains in a simple fashion.

Closes #3.
This commit is contained in:
evilham 2022-03-10 21:28:28 +01:00
parent ac99cd8d84
commit a1b3a034c7
Signed by: evilham
GPG key ID: AE3EE30D970886BF
4 changed files with 33 additions and 3 deletions

View file

@ -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`.

View file

@ -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 "-" <<EOF
${JITSI_NGINX_CONFIG}
EOF
@ -69,6 +91,7 @@ EOF
# shellcheck source=type/__jitsi_meet_domain/files/config.js.sh
. "${__type}/files/config.js.sh" # This defines JITSI_CONFIG_JS
__file "/etc/jitsi/meet/${DOMAIN}-config.js" \
--state "${STATE}" \
--mode 0644 --source "-" <<EOF
${JITSI_CONFIG_JS}
EOF
@ -77,6 +100,7 @@ EOF
# shellcheck source=type/__jitsi_meet_domain/files/interface_config.js.sh
. "${__type}/files/interface_config.js.sh" # This defines JITSI_CONFIG_JS
__file "/etc/jitsi/meet/${DOMAIN}-interface_config.js" \
--state "${STATE}" \
--mode 0644 --source "-" <<EOF
${JITSI_INTERFACE_CONFIG_JS}
EOF
@ -87,7 +111,7 @@ EOF
#
# Helper function to manage the state of the target branding file
_var_state() {
if [ -n "${1}" ]; then
if [ "${STATE}" = "present" ] && [ -n "${1}" ]; then
echo "present"
else
echo "absent"

View file

@ -0,0 +1 @@
present

View file

@ -7,3 +7,4 @@ video-constraints
branding-json
branding-index
branding-watermark
state