Fix ensure_coturn_user leaving callers in the wrong directory
install_coturn (services/coturn.sh) cd's into $DOCKER_DIR/coturn and never restores the caller's original working directory. A consumer that chain- installs coturn mid-flow (e.g. asterisk.sh, already cd'd into its own install directory) returned from ensure_coturn_user still sitting in coturn's directory, then went on to write its own docker-compose.yml/.env there instead of its own directory — clobbering coturn's compose file and leaving the consumer's directory without one. The consumer's later `docker compose up --build` then failed with "Dockerfile: no such file or directory", since the Dockerfile was correctly in the consumer's directory but the misplaced compose file (and the build) were not. ensure_coturn_user now saves/restores the caller's cwd around the install_coturn call, fixing this for every consumer (asterisk, mattermost). Also fold cloud-init.sh's contents into a collapsible README section so it's copy-pasteable straight from the repo instead of requiring a separate file download.
This commit is contained in:
+14
-1
@@ -810,7 +810,20 @@ ensure_coturn_user() {
|
||||
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..."
|
||||
install_coturn || { log_warning "coturn setup failed — $_consumer will run without TURN."; return 1; }
|
||||
# install_coturn cd's into $DOCKER_DIR/coturn and never cd's back —
|
||||
# the caller (e.g. asterisk.sh, already cd'd into its own install
|
||||
# directory) would otherwise return here with the wrong cwd and go
|
||||
# on to write ITS docker-compose.yml/.env into coturn's directory
|
||||
# instead of its own. Confirmed live: this clobbered coturn's
|
||||
# compose file and left the consumer's own directory without one,
|
||||
# so its later `docker compose up --build` failed with "Dockerfile:
|
||||
# no such file or directory" (no Dockerfile in coturn's directory).
|
||||
local _caller_pwd
|
||||
_caller_pwd="$(pwd)"
|
||||
install_coturn
|
||||
local _coturn_rc=$?
|
||||
cd "$_caller_pwd" || true
|
||||
[ "$_coturn_rc" -ne 0 ] && { log_warning "coturn setup failed — $_consumer will run without TURN."; return 1; }
|
||||
else
|
||||
log_warning "services/coturn.sh not loaded — $_consumer will run without TURN."
|
||||
log_warning "Run: sudo ./setup.sh coturn"
|
||||
|
||||
Reference in New Issue
Block a user