Add a flag to permanently retire shared coturn without auto-reinstalling it
ensure_coturn_user() auto-installs shared coturn (services/coturn.sh) any time $DOCKER_DIR/coturn doesn't exist — correct behavior for "first service that needs TURN", wrong behavior for "an operator deliberately decided every consumer should run its own dedicated coturn instead and removed the shared one on purpose". The function had no way to tell those two states apart, so deleting ~/docker/coturn didn't actually retire it — the next service to call this function (a Mattermost reinstall, a fresh Asterisk install) would silently bring it right back. touch ~/docker/.coturn-retired now short-circuits the function straight to the existing "no TURN available, caller degrades gracefully" return path, before it ever looks at install_coturn. Every existing consumer (Asterisk, Mattermost) already handles that path correctly today — it's exactly what happens if shared coturn simply fails to install — so this needed no changes on the consumer side, only closing the gap in the shared function. Verified with a mock: with the flag present, install_coturn is never invoked and the function returns empty COTURN_HOST/rc=1 as expected.
This commit is contained in:
@@ -1031,6 +1031,21 @@ ensure_coturn_user() {
|
||||
local _consumer="$1"
|
||||
COTURN_HOST="" COTURN_PORT="" COTURN_USERNAME="" COTURN_PASSWORD=""
|
||||
|
||||
# An operator can permanently retire shared coturn (e.g. deciding every
|
||||
# consumer should run its own dedicated instance instead) by creating
|
||||
# this flag file. Without checking it here first, retiring shared coturn
|
||||
# by just deleting $DOCKER_DIR/coturn wouldn't actually stick — the very
|
||||
# next service that calls this function (a Mattermost reinstall, a fresh
|
||||
# Asterisk install, ...) would silently reinstall it right back, since
|
||||
# the only signal this function otherwise has is "does the directory
|
||||
# exist yet", which looks identical to "never installed" and "removed on
|
||||
# purpose". touch/rm $DOCKER_DIR/.coturn-retired to toggle this.
|
||||
if [ -f "$DOCKER_DIR/.coturn-retired" ]; then
|
||||
log_info "Shared coturn is retired on this box ($DOCKER_DIR/.coturn-retired exists) —"
|
||||
log_info "$_consumer will run its own dedicated coturn instead."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$DOCKER_DIR/coturn" ]; then
|
||||
if declare -F install_coturn >/dev/null 2>&1; then
|
||||
log_info "No shared coturn (TURN/STUN) server yet — setting one up for $_consumer..."
|
||||
|
||||
Reference in New Issue
Block a user