132 lines
3.6 KiB
Bash
Executable file
132 lines
3.6 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
os="$(cat "${__global}/explorer/os")"
|
|
case "${os}" in
|
|
devuan|debian)
|
|
;;
|
|
*)
|
|
echo "Your OS '${os}' is currently not supported." > /dev/stderr
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
DOMAIN="${__object_id}"
|
|
ADMIN_EMAIL="$(cat "${__object}/parameter/admin-email")"
|
|
CHANNEL_LAST_N="$(cat "${__object}/parameter/channel-last-n")"
|
|
DEFAULT_LANGUAGE="$(cat "${__object}/parameter/default-language")"
|
|
NOTICE_MESSAGE="$(cat "${__object}/parameter/notice-message")"
|
|
START_VIDEO_MUTED="$(cat "${__object}/parameter/start-video-muted")"
|
|
TURN_SERVER="$(cat "${__object}/parameter/turn-server")"
|
|
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"
|
|
fi
|
|
|
|
if [ -f "${__object}/parameter/enable-third-party-requests" ]; then
|
|
ENABLE_THIRD_PARTY_REQUESTS="YES"
|
|
fi
|
|
if [ -f "${__object}/parameter/disable-audio-levels" ]; then
|
|
DISABLE_AUDIO_LEVELS="YES"
|
|
fi
|
|
if [ -f "${__object}/parameter/secured-domains" ]; then
|
|
SECURED_DOMAINS="YES"
|
|
fi
|
|
|
|
if [ -z "${TURN_SERVER}" ]; then
|
|
TURN_SERVER="${__target_host}"
|
|
fi
|
|
if [ -z "${JITSI_HOST}" ]; then
|
|
JITSI_HOST="${__target_host}"
|
|
fi
|
|
|
|
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
|
|
require="${le_require}" __letsencrypt_cert "${DOMAIN}" \
|
|
--state "${STATE}" \
|
|
--admin-email "${ADMIN_EMAIL}" \
|
|
--deploy-hook "service nginx reload" \
|
|
--webroot /usr/share/jitsi-meet
|
|
|
|
# Create virtualhost for nginx
|
|
# shellcheck source=type/__jitsi_meet_domain/files/nginx.sh
|
|
. "${__type}/files/nginx.sh" # This defines JITSI_NGINX_CONFIG
|
|
require="${nginx_require}" __file \
|
|
"/etc/nginx/sites-enabled/${DOMAIN}.conf" \
|
|
--state "${STATE}" \
|
|
--mode 0644 --source "-" <<EOF
|
|
${JITSI_NGINX_CONFIG}
|
|
EOF
|
|
|
|
# Setup jitsi config
|
|
# 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
|
|
|
|
# Setup jitsi interface config
|
|
# 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
|
|
|
|
|
|
#
|
|
# Deal with branding as requested
|
|
#
|
|
# Helper function to manage the state of the target branding file
|
|
_var_state() {
|
|
if [ "${STATE}" = "present" ] && [ -n "${1}" ]; then
|
|
echo "present"
|
|
else
|
|
echo "absent"
|
|
fi
|
|
}
|
|
|
|
__file "/usr/share/jitsi-meet/index-${DOMAIN}.html" \
|
|
--mode 0644 \
|
|
--state "$(_var_state "${BRANDING_INDEX}")" \
|
|
--source "${BRANDING_INDEX}"
|
|
__file "/etc/jitsi/meet/${DOMAIN}-branding.json" \
|
|
--mode 0644 \
|
|
--state "$(_var_state "${BRANDING_JSON}")" \
|
|
--source "${BRANDING_JSON}"
|
|
__file "/usr/share/jitsi-meet/images/watermark-${DOMAIN}.png" \
|
|
--mode 0644 \
|
|
--state "$(_var_state "${BRANDING_WATERMARK}")" \
|
|
--source "${BRANDING_WATERMARK}"
|