Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions bin/baudbot
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,27 @@ case "${1:-}" in

update)
shift
# For now: git pull + deploy
require_root "update"
echo "=== Pulling latest ==="
cd "$BAUDBOT_ROOT"
git pull origin main
echo ""
echo "=== Deploying ==="
exec "$BAUDBOT_ROOT/bin/deploy.sh" "$@"
"$BAUDBOT_ROOT/bin/deploy.sh" "$@"
echo ""
# Restart if currently running
if has_systemd && systemctl is-active baudbot &>/dev/null 2>&1; then
Comment thread
benvinegar marked this conversation as resolved.
Outdated
echo "=== Restarting ==="
systemctl restart baudbot
sleep 2
if systemctl is-active baudbot &>/dev/null 2>&1; then
Comment thread
benvinegar marked this conversation as resolved.
Outdated
echo "✅ Updated and running"
else
echo "⚠️ Deployed but agent didn't restart — check: baudbot logs"
fi
else
echo "✅ Updated. Start with: sudo baudbot start"
fi
;;

uninstall)
Expand Down
14 changes: 12 additions & 2 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,18 @@ fi
echo "Deploying config..."

# Determine who invoked this (the admin user)
# BAUDBOT_CONFIG_USER env var overrides detection (used by install.sh)
DEPLOY_USER="${BAUDBOT_CONFIG_USER:-${SUDO_USER:-$(whoami)}}"
# Priority: BAUDBOT_CONFIG_USER env > SUDO_USER > repo owner > whoami
if [ -n "${BAUDBOT_CONFIG_USER:-}" ]; then
DEPLOY_USER="$BAUDBOT_CONFIG_USER"
elif [ -n "${SUDO_USER:-}" ] && [ "${SUDO_USER}" != "root" ]; then
Comment thread
benvinegar marked this conversation as resolved.
Outdated
DEPLOY_USER="$SUDO_USER"
else
# Detect from repo ownership (the admin owns the source)
DEPLOY_USER=$(stat -c '%U' "$BAUDBOT_SRC" 2>/dev/null || echo "")
if [ -z "$DEPLOY_USER" ] || [ "$DEPLOY_USER" = "root" ]; then
DEPLOY_USER="$(whoami)"
fi
fi
DEPLOY_HOME=$(getent passwd "$DEPLOY_USER" | cut -d: -f6 2>/dev/null || echo "")
ADMIN_CONFIG="$DEPLOY_HOME/.baudbot/.env"

Expand Down