Update entrypoint.sh
Browse files- entrypoint.sh +60 -8
entrypoint.sh
CHANGED
|
@@ -8,7 +8,7 @@ export HF_TOKEN="${HF_TOKEN}"
|
|
| 8 |
|
| 9 |
# Variables
|
| 10 |
BUCKET='hf://buckets/bk939448/opencodeai'
|
| 11 |
-
SOURCE='/
|
| 12 |
|
| 13 |
# Configure Git
|
| 14 |
git config --global user.email 'badal@example.com'
|
|
@@ -30,7 +30,25 @@ echo '=== [STEP 0] BUCKET CLEANUP DONE ==='
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
echo '=== [STEP 1] RESTORE COMPLETE ==='
|
| 35 |
else
|
| 36 |
echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
|
|
@@ -57,16 +75,50 @@ while true; do
|
|
| 57 |
exit 1
|
| 58 |
fi
|
| 59 |
|
| 60 |
-
# Wait for any file change in /
|
| 61 |
-
# Excludes .mdb
|
| 62 |
inotifywait -r -e modify,create,delete,move \
|
| 63 |
--exclude '.*\.mdb$' \
|
| 64 |
-
--exclude '
|
| 65 |
-
--exclude '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
-q "$SOURCE"
|
| 67 |
|
| 68 |
-
# Change detected! Sync to bucket (excluding
|
| 69 |
echo "=== [STEP 3] Change detected! Syncing to bucket... ==="
|
| 70 |
-
hf sync "$SOURCE" "$BUCKET" --delete
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
echo "=== [STEP 3] Sync done! Waiting for next change... ==="
|
| 72 |
done
|
|
|
|
| 8 |
|
| 9 |
# Variables
|
| 10 |
BUCKET='hf://buckets/bk939448/opencodeai'
|
| 11 |
+
SOURCE='/'
|
| 12 |
|
| 13 |
# Configure Git
|
| 14 |
git config --global user.email 'badal@example.com'
|
|
|
|
| 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 \
|
| 34 |
+
--exclude "boot/*" \
|
| 35 |
+
--exclude "dev/*" \
|
| 36 |
+
--exclude "proc/*" \
|
| 37 |
+
--exclude "sys/*" \
|
| 38 |
+
--exclude "run/*" \
|
| 39 |
+
--exclude "tmp/*" \
|
| 40 |
+
--exclude "media/*" \
|
| 41 |
+
--exclude "mnt/*" \
|
| 42 |
+
--exclude "srv/*" \
|
| 43 |
+
--exclude "lib/*" \
|
| 44 |
+
--exclude "lib64/*" \
|
| 45 |
+
--exclude "bin/*" \
|
| 46 |
+
--exclude "sbin/*" \
|
| 47 |
+
--exclude "usr/*" \
|
| 48 |
+
--exclude "opt/*" \
|
| 49 |
+
--exclude "var/*" \
|
| 50 |
+
--exclude "entrypoint.sh" \
|
| 51 |
+
2>/dev/null; then
|
| 52 |
echo '=== [STEP 1] RESTORE COMPLETE ==='
|
| 53 |
else
|
| 54 |
echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
|
|
|
|
| 75 |
exit 1
|
| 76 |
fi
|
| 77 |
|
| 78 |
+
# Wait for any file change in / (blocks until change detected)
|
| 79 |
+
# Excludes system folders + .mdb + .cache + .npm from triggering sync
|
| 80 |
inotifywait -r -e modify,create,delete,move \
|
| 81 |
--exclude '.*\.mdb$' \
|
| 82 |
+
--exclude '^/boot(/.*)?$' \
|
| 83 |
+
--exclude '^/dev(/.*)?$' \
|
| 84 |
+
--exclude '^/proc(/.*)?$' \
|
| 85 |
+
--exclude '^/sys(/.*)?$' \
|
| 86 |
+
--exclude '^/run(/.*)?$' \
|
| 87 |
+
--exclude '^/tmp(/.*)?$' \
|
| 88 |
+
--exclude '^/media(/.*)?$' \
|
| 89 |
+
--exclude '^/mnt(/.*)?$' \
|
| 90 |
+
--exclude '^/srv(/.*)?$' \
|
| 91 |
+
--exclude '^/lib(/.*)?$' \
|
| 92 |
+
--exclude '^/lib64(/.*)?$' \
|
| 93 |
+
--exclude '^/bin(/.*)?$' \
|
| 94 |
+
--exclude '^/sbin(/.*)?$' \
|
| 95 |
+
--exclude '^/usr(/.*)?$' \
|
| 96 |
+
--exclude '^/opt(/.*)?$' \
|
| 97 |
+
--exclude '^/var(/.*)?$' \
|
| 98 |
+
--exclude '^/.*\.cache(/.*)?$' \
|
| 99 |
+
--exclude '^/.*\.npm(/.*)?$' \
|
| 100 |
-q "$SOURCE"
|
| 101 |
|
| 102 |
+
# Change detected! Sync to bucket (excluding system folders + .mdb)
|
| 103 |
echo "=== [STEP 3] Change detected! Syncing to bucket... ==="
|
| 104 |
+
hf sync "$SOURCE" "$BUCKET" --delete \
|
| 105 |
+
--exclude "*.mdb" \
|
| 106 |
+
--exclude "boot/*" \
|
| 107 |
+
--exclude "dev/*" \
|
| 108 |
+
--exclude "proc/*" \
|
| 109 |
+
--exclude "sys/*" \
|
| 110 |
+
--exclude "run/*" \
|
| 111 |
+
--exclude "tmp/*" \
|
| 112 |
+
--exclude "media/*" \
|
| 113 |
+
--exclude "mnt/*" \
|
| 114 |
+
--exclude "srv/*" \
|
| 115 |
+
--exclude "lib/*" \
|
| 116 |
+
--exclude "lib64/*" \
|
| 117 |
+
--exclude "bin/*" \
|
| 118 |
+
--exclude "sbin/*" \
|
| 119 |
+
--exclude "usr/*" \
|
| 120 |
+
--exclude "opt/*" \
|
| 121 |
+
--exclude "var/*" \
|
| 122 |
+
--exclude "entrypoint.sh"
|
| 123 |
echo "=== [STEP 3] Sync done! Waiting for next change... ==="
|
| 124 |
done
|