Badal commited on
Commit
65fa4a5
·
1 Parent(s): 80c440d

Explicit steps: 1) Clean bucket 2) Restore 3) Start OpenCode 4) Sync

Browse files
Files changed (1) hide show
  1. entrypoint.sh +20 -11
entrypoint.sh CHANGED
@@ -19,29 +19,37 @@ OP_PATH=$(find / -name opencode -type f -printf '%h' -quit 2>/dev/null)
19
  export PATH="$OP_PATH:$PATH"
20
 
21
  # ============================================
22
- # STEP 1: RESTORE (Bucket is already clean - no .cache/.npm)
23
  # ============================================
24
- echo '=== [STEP 1] RESTORING DATA FROM BUCKET ==='
 
 
 
 
 
 
 
 
25
  if hf sync "$BUCKET" "$SOURCE" --delete 2>/dev/null; then
26
- echo '=== [STEP 1] RESTORE COMPLETE ==='
27
  else
28
- echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
29
  fi
30
 
31
  # ============================================
32
- # STEP 2: START OPENCODE
33
  # ============================================
34
- echo '=== [STEP 2] STARTING OPENCODE ==='
35
  export OPENCODE_SERVER_USERNAME=${OPENCODE_SERVER_USERNAME}
36
  export OPENCODE_SERVER_PASSWORD=${OPENCODE_SERVER_PASSWORD}
37
  opencode web --port 7860 --hostname 0.0.0.0 > /tmp/opencode.log 2>&1 &
38
  sleep 10
39
- echo '=== [STEP 2] OPENCODE STARTED ==='
40
 
41
  # ============================================
42
- # STEP 3: REAL-TIME CONTINUOUS SYNC
43
  # ============================================
44
- echo '=== [STEP 3] STARTING REAL-TIME SYNC ==='
45
  while true; do
46
  # Check if OpenCode is still running
47
  if ! pgrep -f 'opencode' > /dev/null; then
@@ -49,6 +57,7 @@ while true; do
49
  exit 1
50
  fi
51
 
52
- # Real-time continuous sync (no interval - continuous!)
53
- hf sync "$SOURCE" "$BUCKET" --delete
 
54
  done
 
19
  export PATH="$OP_PATH:$PATH"
20
 
21
  # ============================================
22
+ # STEP 1: DELETE .cache AND .npm FROM BUCKET
23
  # ============================================
24
+ echo '=== [STEP 1] CLEANING BUCKET - DELETING .cache AND .npm ==='
25
+ hf buckets rm bk939448/opencodeai/.cache -R -y 2>/dev/null || echo ".cache already deleted or not found"
26
+ hf buckets rm bk939448/opencodeai/.npm -R -y 2>/dev/null || echo ".npm already deleted or not found"
27
+ echo '=== [STEP 1] BUCKET CLEAN COMPLETE ==='
28
+
29
+ # ============================================
30
+ # STEP 2: RESTORE FROM CLEANED BUCKET
31
+ # ============================================
32
+ echo '=== [STEP 2] RESTORING DATA FROM BUCKET ==='
33
  if hf sync "$BUCKET" "$SOURCE" --delete 2>/dev/null; then
34
+ echo '=== [STEP 2] RESTORE COMPLETE ==='
35
  else
36
+ echo '=== [STEP 2] Restore skipped (bucket empty or failed - continuing anyway) ==='
37
  fi
38
 
39
  # ============================================
40
+ # STEP 3: START OPENCODE
41
  # ============================================
42
+ echo '=== [STEP 3] STARTING OPENCODE ==='
43
  export OPENCODE_SERVER_USERNAME=${OPENCODE_SERVER_USERNAME}
44
  export OPENCODE_SERVER_PASSWORD=${OPENCODE_SERVER_PASSWORD}
45
  opencode web --port 7860 --hostname 0.0.0.0 > /tmp/opencode.log 2>&1 &
46
  sleep 10
47
+ echo '=== [STEP 3] OPENCODE STARTED ==='
48
 
49
  # ============================================
50
+ # STEP 4: REAL-TIME CONTINUOUS SYNC
51
  # ============================================
52
+ echo '=== [STEP 4] STARTING REAL-TIME SYNC ==='
53
  while true; do
54
  # Check if OpenCode is still running
55
  if ! pgrep -f 'opencode' > /dev/null; then
 
57
  exit 1
58
  fi
59
 
60
+ # Real-time continuous sync (quiet mode)
61
+ hf sync "$SOURCE" "$BUCKET" --delete --quiet
62
+ sleep 2
63
  done