bk939448 commited on
Commit
21d9222
·
verified ·
1 Parent(s): 65fa4a5

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +16 -17
entrypoint.sh CHANGED
@@ -19,37 +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: 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,7 +57,6 @@ while true; do
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
 
19
  export PATH="$OP_PATH:$PATH"
20
 
21
  # ============================================
22
+ # STEP 0: BUCKET CLEANUP (Delete .cache & .npm from bucket)
23
  # ============================================
24
+ echo '=== [STEP 0] CLEANING BUCKET (Removing .cache and .npm) ==='
25
+ hf buckets rm "$BUCKET/.cache" --recursive 2>/dev/null && echo '=== [STEP 0] .cache removed from bucket ===' || echo '=== [STEP 0] .cache not found in bucket (skipping) ==='
26
+ hf buckets rm "$BUCKET/.npm" --recursive 2>/dev/null && echo '=== [STEP 0] .npm removed from bucket ===' || echo '=== [STEP 0] .npm not found in bucket (skipping) ==='
27
+ echo '=== [STEP 0] BUCKET CLEANUP DONE ==='
28
 
29
  # ============================================
30
+ # STEP 1: RESTORE (Try, but continue if bucket empty)
31
  # ============================================
32
+ echo '=== [STEP 1] RESTORING DATA FROM BUCKET ==='
33
  if hf sync "$BUCKET" "$SOURCE" --delete 2>/dev/null; then
34
+ echo '=== [STEP 1] RESTORE COMPLETE ==='
35
  else
36
+ echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
37
  fi
38
 
39
  # ============================================
40
+ # STEP 2: START OPENCODE
41
  # ============================================
42
+ echo '=== [STEP 2] 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 2] OPENCODE STARTED ==='
48
 
49
  # ============================================
50
+ # STEP 3: REAL-TIME CONTINUOUS SYNC
51
  # ============================================
52
+ echo '=== [STEP 3] 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 (no interval - continuous!)
61
+ hf sync "$SOURCE" "$BUCKET" --delete --exclude "*.mdb"
 
62
  done