amangs commited on
Commit
95762da
·
verified ·
1 Parent(s): 5aa2b81

Fix shell variable expansion in start.sh

Browse files
Files changed (1) hide show
  1. start.sh +10 -10
start.sh CHANGED
@@ -6,9 +6,9 @@ BUCKET_DIR="/data/openclaw"
6
  EXCLUDES=(--exclude="cache/" --exclude="logs/" --exclude="tmp/" --exclude="*.sock" --exclude="*.lock*")
7
 
8
  # 1. Restore on boot
9
- if [ -d "" ] && [ "" ]; then
10
- echo "[Storage] Restoring from ..."
11
- rsync -a "" "/" "/"
12
  echo "[Storage] Restore completed."
13
  fi
14
 
@@ -17,19 +17,19 @@ openclaw doctor --fix --yes 2>/dev/null || true
17
 
18
  # 3. Background sync to bucket every 30s
19
  if [ -d "/data" ]; then
20
- mkdir -p ""
21
  (
22
  set +e
23
  while true; do
24
  sleep 30
25
 
26
- for db in ""/state/*.sqlite ""/agents/*/agent/*.sqlite; do
27
- if [ -f "" ]; then
28
- python3 -c "import sqlite3; c=sqlite3.connect(''); c.execute('PRAGMA wal_checkpoint(PASSIVE);'); c.close()" 2>/dev/null || true
29
  fi
30
  done
31
 
32
- rsync -a --delete "" "/" "/" 2>/dev/null || true
33
  done
34
  ) &
35
  fi
@@ -37,12 +37,12 @@ fi
37
  # 4. Graceful shutdown sync
38
  sync_exit() {
39
  echo "[Storage] Container stopping, running final sync..."
40
- rsync -a --delete "" "/" "/" 2>/dev/null || true
41
  exit 0
42
  }
43
  trap sync_exit SIGTERM SIGINT
44
 
45
- chmod -R 700 ""
46
 
47
  # 5. Start gateway
48
  exec openclaw gateway run --port 7860
 
6
  EXCLUDES=(--exclude="cache/" --exclude="logs/" --exclude="tmp/" --exclude="*.sock" --exclude="*.lock*")
7
 
8
  # 1. Restore on boot
9
+ if [ -d "$BUCKET_DIR" ] && [ "$(ls -A "$BUCKET_DIR" 2>/dev/null)" ]; then
10
+ echo "[Storage] Restoring from $BUCKET_DIR..."
11
+ rsync -a "${EXCLUDES[@]}" "$BUCKET_DIR/" "$OPENCLAW_DIR/"
12
  echo "[Storage] Restore completed."
13
  fi
14
 
 
17
 
18
  # 3. Background sync to bucket every 30s
19
  if [ -d "/data" ]; then
20
+ mkdir -p "$BUCKET_DIR"
21
  (
22
  set +e
23
  while true; do
24
  sleep 30
25
 
26
+ for db in "$OPENCLAW_DIR"/state/*.sqlite "$OPENCLAW_DIR"/agents/*/agent/*.sqlite; do
27
+ if [ -f "$db" ]; then
28
+ python3 -c "import sqlite3; c=sqlite3.connect('$db'); c.execute('PRAGMA wal_checkpoint(PASSIVE);'); c.close()" 2>/dev/null || true
29
  fi
30
  done
31
 
32
+ rsync -a --delete "${EXCLUDES[@]}" "$OPENCLAW_DIR/" "$BUCKET_DIR/" 2>/dev/null || true
33
  done
34
  ) &
35
  fi
 
37
  # 4. Graceful shutdown sync
38
  sync_exit() {
39
  echo "[Storage] Container stopping, running final sync..."
40
+ rsync -a --delete "${EXCLUDES[@]}" "$OPENCLAW_DIR/" "$BUCKET_DIR/" 2>/dev/null || true
41
  exit 0
42
  }
43
  trap sync_exit SIGTERM SIGINT
44
 
45
+ chmod -R 700 "$OPENCLAW_DIR"
46
 
47
  # 5. Start gateway
48
  exec openclaw gateway run --port 7860