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
10 changes: 10 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ if [ -d "$SCRIPTS_SOURCE_DIR" ]; then
chmod +x "$INTERNAL_SCRIPTS_DIR/upgrade-watchdog.sh"
echo "✓ Upgrade watchdog script deployed"

# Backward compatibility: also deploy to /data/scripts/ for older sidecar configs
# that still reference the old path (command: /data/scripts/upgrade-watchdog.sh)
# Only deploy if /data/scripts exists or can be created (skip if bind-mounted with other content)
LEGACY_SCRIPTS_DIR="/data/scripts"
if mkdir -p "$LEGACY_SCRIPTS_DIR" 2>/dev/null; then
cp "$SCRIPTS_SOURCE_DIR/upgrade-watchdog.sh" "$LEGACY_SCRIPTS_DIR/upgrade-watchdog.sh"
chmod +x "$LEGACY_SCRIPTS_DIR/upgrade-watchdog.sh"
echo "✓ Upgrade watchdog script also deployed to $LEGACY_SCRIPTS_DIR (backward compat)"
fi

# Audit log the deployment
if [ -w "$(dirname "$AUDIT_LOG")" ]; then
echo "{\"timestamp\":\"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\",\"event\":\"upgrade_script_deployed\",\"script_hash\":\"$SCRIPT_HASH\",\"version\":\"${npm_package_version:-unknown}\",\"user\":\"system\"}" >> "$AUDIT_LOG" 2>/dev/null || true
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/auto-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The auto-upgrade feature uses a **watchdog sidecar** container that:
### Docker Compose Setup

::: info
The upgrade watchdog script is automatically deployed to `/data/scripts/` by the MeshMonitor container on startup. No manual script download is required.
The upgrade watchdog script is automatically deployed to `/data/.meshmonitor-internal/` by the MeshMonitor container on startup. No manual script download is required.
:::

1. **Enable the watchdog sidecar** by using the upgrade overlay:
Expand Down
21 changes: 19 additions & 2 deletions scripts/upgrade-watchdog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,21 @@ pull_image() {
recreate_container() {
log "Recreating container: $CONTAINER_NAME"

# Resolve compose directory - try configured path, then standard mount point
# Resolve compose directory - try configured path, then known mount points
# Older sidecar configs used /data/compose, current uses /compose
local compose_dir=""
if [ -d "$COMPOSE_PROJECT_DIR" ] && [ -f "$COMPOSE_PROJECT_DIR/docker-compose.yml" ]; then
compose_dir="$COMPOSE_PROJECT_DIR"
elif [ -d "/compose" ] && [ -f "/compose/docker-compose.yml" ]; then
log_warn "COMPOSE_PROJECT_DIR=$COMPOSE_PROJECT_DIR not found, falling back to /compose"
compose_dir="/compose"
elif [ -d "/data/compose" ] && [ -f "/data/compose/docker-compose.yml" ]; then
log_warn "Falling back to legacy path /data/compose - please update COMPOSE_PROJECT_DIR to /compose"
compose_dir="/data/compose"
fi

if [ -z "$compose_dir" ]; then
log_error "No docker-compose.yml found at $COMPOSE_PROJECT_DIR or /compose"
log_error "No docker-compose.yml found at $COMPOSE_PROJECT_DIR, /compose, or /data/compose"
log_error "The upgrade sidecar requires Docker Compose files to recreate containers safely."
log_error "Mount your compose directory to /compose in the sidecar container."
return 1
Expand Down Expand Up @@ -486,6 +490,19 @@ main() {
log "Compose project: $COMPOSE_PROJECT_DIR"
log "=================================================="

# Warn if running from the legacy script path
SCRIPT_PATH="$(readlink -f "$0" 2>/dev/null || echo "$0")"
case "$SCRIPT_PATH" in
/data/scripts/*)
log_warn "=================================================="
log_warn "Running from legacy path: $SCRIPT_PATH"
log_warn "Please update your docker-compose.upgrade.yml to use:"
log_warn " command: /data/.meshmonitor-internal/upgrade-watchdog.sh"
log_warn "See: https://github.com/Yeraze/meshmonitor/blob/main/docker-compose.upgrade.yml"
log_warn "=================================================="
;;
esac

# Initialize status
write_status "ready"

Expand Down
Loading