Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ jobs:
- run: bun x tsc --noEmit
- run: bun test
- run: node --test test/agent-phone.test.mjs
- run: bash -n bin/install.sh
1 change: 1 addition & 0 deletions bin/install.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ PORT=8810
HEALTH_PATH=/health
DOMAINS=
ACCESS_LOG=off
AGENT_PHONE_USER=anthony
23 changes: 23 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,35 @@ phase_setup() {
log "setup ok: runtime=$RUNTIME state=$STATE_DIR"
}

install_agent_phone() {
[ "$APP" = group-call ] || return 0
[ -f "$SRC_DIR/ops/agent-phone.mjs" ] || return 0
local worker_user worker_home worker_group worker_node
worker_user="${AGENT_PHONE_USER:-anthony}"
worker_home="$(getent passwd "$worker_user" | cut -d: -f6)"
[ -n "$worker_home" ] || die "AGENT_PHONE_USER '$worker_user' has no home directory"
worker_group="$(id -gn "$worker_user")"
worker_node="$worker_home/.local/share/mise/shims/node"
[ -x "$worker_node" ] || die "agent worker node runtime missing: $worker_node"
install -d -o "$worker_user" -g "$worker_group" -m 0750 "$worker_home/.local/share/agent-phone" "$worker_home/.local/bin"
install -o "$worker_user" -g "$worker_group" -m 0750 "$SRC_DIR/ops/agent-phone.mjs" "$worker_home/.local/share/agent-phone/agent-phone.mjs"
cat > "$worker_home/.local/bin/agent-phone.tmp" <<EOF
#!/bin/sh
exec $worker_node $worker_home/.local/share/agent-phone/agent-phone.mjs "\$@"
EOF
chown "$worker_user:$worker_group" "$worker_home/.local/bin/agent-phone.tmp"
chmod 0750 "$worker_home/.local/bin/agent-phone.tmp"
mv "$worker_home/.local/bin/agent-phone.tmp" "$worker_home/.local/bin/agent-phone"
log "agent worker installed for $worker_user"
}

phase_build() {
detect
load_env
cd "$SRC_DIR"
if [ "$INSTALL_CMD" != none ]; then log "install: $INSTALL_CMD"; bash -c "$INSTALL_CMD"; fi
if [ "$BUILD_CMD" != none ]; then log "build: $BUILD_CMD"; NODE_ENV=production bash -c "$BUILD_CMD"; fi
install_agent_phone
log "build ok"
}

Expand Down
Loading