Update entrypoint.sh
Browse files- entrypoint.sh +9 -62
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,25 +30,7 @@ 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 |
-
--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,51 +57,16 @@ while true; do
|
|
| 75 |
exit 1
|
| 76 |
fi
|
| 77 |
|
| 78 |
-
# Wait for any file change in / (blocks until change detected)
|
| 79 |
-
# Excludes
|
| 80 |
-
# FIXED: inotifywait regex patterns को सही format में बदला - full path matching के लिए
|
| 81 |
inotifywait -r -e modify,create,delete,move \
|
| 82 |
-
--exclude '.
|
| 83 |
-
--exclude '/
|
| 84 |
-
--exclude '/
|
| 85 |
-
--exclude '/proc(/.*)?' \
|
| 86 |
-
--exclude '/sys(/.*)?' \
|
| 87 |
-
--exclude '/run(/.*)?' \
|
| 88 |
-
--exclude '/tmp(/.*)?' \
|
| 89 |
-
--exclude '/media(/.*)?' \
|
| 90 |
-
--exclude '/mnt(/.*)?' \
|
| 91 |
-
--exclude '/srv(/.*)?' \
|
| 92 |
-
--exclude '/lib(/.*)?' \
|
| 93 |
-
--exclude '/lib64(/.*)?' \
|
| 94 |
-
--exclude '/bin(/.*)?' \
|
| 95 |
-
--exclude '/sbin(/.*)?' \
|
| 96 |
-
--exclude '/usr(/.*)?' \
|
| 97 |
-
--exclude '/opt(/.*)?' \
|
| 98 |
-
--exclude '/var(/.*)?' \
|
| 99 |
-
--exclude '/..*cache(/.*)?' \
|
| 100 |
-
--exclude '/..*npm(/.*)?' \
|
| 101 |
-q "$SOURCE"
|
| 102 |
|
| 103 |
-
# Change detected! Sync to bucket (excluding
|
| 104 |
echo "=== [STEP 3] Change detected! Syncing to bucket... ==="
|
| 105 |
-
hf sync "$SOURCE" "$BUCKET" --delete
|
| 106 |
-
--exclude "*.mdb" \
|
| 107 |
-
--exclude "boot/*" \
|
| 108 |
-
--exclude "dev/*" \
|
| 109 |
-
--exclude "proc/*" \
|
| 110 |
-
--exclude "sys/*" \
|
| 111 |
-
--exclude "run/*" \
|
| 112 |
-
--exclude "tmp/*" \
|
| 113 |
-
--exclude "media/*" \
|
| 114 |
-
--exclude "mnt/*" \
|
| 115 |
-
--exclude "srv/*" \
|
| 116 |
-
--exclude "lib/*" \
|
| 117 |
-
--exclude "lib64/*" \
|
| 118 |
-
--exclude "bin/*" \
|
| 119 |
-
--exclude "sbin/*" \
|
| 120 |
-
--exclude "usr/*" \
|
| 121 |
-
--exclude "opt/*" \
|
| 122 |
-
--exclude "var/*" \
|
| 123 |
-
--exclude "entrypoint.sh"
|
| 124 |
echo "=== [STEP 3] Sync done! Waiting for next change... ==="
|
| 125 |
done
|
|
|
|
| 8 |
|
| 9 |
# Variables
|
| 10 |
BUCKET='hf://buckets/bk939448/opencodeai'
|
| 11 |
+
SOURCE='/home/user'
|
| 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 2>/dev/null; then
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
echo '=== [STEP 1] RESTORE COMPLETE ==='
|
| 35 |
else
|
| 36 |
echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
|
|
|
|
| 57 |
exit 1
|
| 58 |
fi
|
| 59 |
|
| 60 |
+
# Wait for any file change in /home/user (blocks until change detected)
|
| 61 |
+
# Excludes .mdb files, .cache folder, .npm folder from triggering sync
|
|
|
|
| 62 |
inotifywait -r -e modify,create,delete,move \
|
| 63 |
+
--exclude '.*\.mdb$' \
|
| 64 |
+
--exclude '.*/\.cache(/.*)?$' \
|
| 65 |
+
--exclude '.*/\.npm(/.*)?$' \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
-q "$SOURCE"
|
| 67 |
|
| 68 |
+
# Change detected! Sync to bucket (excluding .mdb, .cache, .npm)
|
| 69 |
echo "=== [STEP 3] Change detected! Syncing to bucket... ==="
|
| 70 |
+
hf sync "$SOURCE" "$BUCKET" --delete --exclude "*.mdb"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
echo "=== [STEP 3] Sync done! Waiting for next change... ==="
|
| 72 |
done
|