smodusermc commited on
Commit
28fdcd9
Β·
verified Β·
1 Parent(s): cefd39d

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +82 -1
start.sh CHANGED
@@ -13,7 +13,10 @@ PLUGIN_DIR="$BACKEND_DIR/plugins"
13
 
14
  mkdir -p "$PLUGIN_DIR"
15
 
16
- HF_BUCKET_HANDLE="hf://buckets/jshshdgxh/mc"
 
 
 
17
  SAVE_DIRS="world world_nether world_the_end players banned-ips.json banned-players.json ops.json whitelist.json"
18
  SYNC_INTERVAL="${SYNC_INTERVAL:-300}"
19
 
@@ -256,6 +259,84 @@ hf_sync_loop() {
256
  echo "[0/6] Bucket setup..."
257
  hf_authenticate
258
  hf_ensure_bucket
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  hf_restore_saves
260
  echo ""
261
 
 
13
 
14
  mkdir -p "$PLUGIN_DIR"
15
 
16
+ # =============================================
17
+ # NEW BUCKET β€” now the active one
18
+ # =============================================
19
+ HF_BUCKET_HANDLE="hf://buckets/smodusermc/mc"
20
  SAVE_DIRS="world world_nether world_the_end players banned-ips.json banned-players.json ops.json whitelist.json"
21
  SYNC_INTERVAL="${SYNC_INTERVAL:-300}"
22
 
 
259
  echo "[0/6] Bucket setup..."
260
  hf_authenticate
261
  hf_ensure_bucket
262
+
263
+ # ╔════════════════════════════════════════════════════════════╗
264
+ # β•‘ >>> REMOVE START β€” ONE-TIME MIGRATION FROM OLD BUCKET β•‘
265
+ # β•‘ Delete everything between REMOVE START and REMOVE END β•‘
266
+ # β•‘ after the first successful run. β•‘
267
+ # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
268
+ OLD_BUCKET="hf://buckets/jshshdgxh/mc"
269
+ MIGRATION_MARKER="/tmp/.bucket_migration_done"
270
+
271
+ if [ ! -f "$MIGRATION_MARKER" ]; then
272
+ echo ""
273
+ echo "========================================"
274
+ echo " MIGRATION: Copying old bucket -> new bucket"
275
+ echo " Old: $OLD_BUCKET"
276
+ echo " New: $HF_BUCKET_HANDLE"
277
+ echo "========================================"
278
+
279
+ # Step 1: Pull everything from old bucket into a temp directory
280
+ MIGRATION_DIR="/tmp/hf-migration"
281
+ rm -rf "$MIGRATION_DIR" && mkdir -p "$MIGRATION_DIR"
282
+
283
+ echo " [MIGRATE] Downloading from old bucket..."
284
+ hf buckets sync "${OLD_BUCKET}/game-data" "$MIGRATION_DIR" 2>&1 | tail -10
285
+
286
+ # Show what we got
287
+ MIGRATED_ITEMS=0
288
+ for item in $SAVE_DIRS; do
289
+ if [ -e "$MIGRATION_DIR/$item" ]; then
290
+ echo " [MIGRATE] Found: $item"
291
+ MIGRATED_ITEMS=$((MIGRATED_ITEMS + 1))
292
+ fi
293
+ done
294
+
295
+ if [ "$MIGRATED_ITEMS" -gt 0 ]; then
296
+ # Step 2: Push everything to the new bucket
297
+ echo " [MIGRATE] Uploading to new bucket..."
298
+ hf buckets sync "$MIGRATION_DIR" "${HF_BUCKET_HANDLE}/game-data" 2>&1 | tail -10
299
+
300
+ if [ $? -eq 0 ]; then
301
+ echo " [MIGRATE] SUCCESS β€” $MIGRATED_ITEMS items copied to new bucket"
302
+ touch "$MIGRATION_MARKER"
303
+ else
304
+ echo " [MIGRATE] WARNING β€” Upload to new bucket may have failed, check logs"
305
+ echo " [MIGRATE] Continuing anyway (old data still in temp dir: $MIGRATION_DIR)"
306
+ fi
307
+ else
308
+ echo " [MIGRATE] No game data found in old bucket (empty or wrong path)"
309
+ echo " [MIGRATE] Skipping migration, will start fresh"
310
+ touch "$MIGRATION_MARKER"
311
+ fi
312
+
313
+ # Also copy any non-game-data top-level files from old bucket
314
+ echo " [MIGRATE] Checking for other files in old bucket root..."
315
+ MIGRATION_ROOT="/tmp/hf-migration-root"
316
+ rm -rf "$MIGRATION_ROOT" && mkdir -p "$MIGRATION_ROOT"
317
+ hf buckets sync "${OLD_BUCKET}" "$MIGRATION_ROOT" 2>&1 | tail -5
318
+
319
+ # Push entire root to new bucket (preserves folder structure)
320
+ if [ "$(ls -A "$MIGRATION_ROOT" 2>/dev/null)" ]; then
321
+ echo " [MIGRATE] Uploading full bucket contents to new bucket..."
322
+ hf buckets sync "$MIGRATION_ROOT" "${HF_BUCKET_HANDLE}" 2>&1 | tail -5
323
+ echo " [MIGRATE] Full bucket copy complete"
324
+ fi
325
+
326
+ rm -rf "$MIGRATION_ROOT"
327
+ rm -rf "$MIGRATION_DIR"
328
+
329
+ echo "========================================"
330
+ echo " MIGRATION COMPLETE"
331
+ echo " You can now delete the migration block"
332
+ echo " from this script (between REMOVE markers)"
333
+ echo "========================================"
334
+ echo ""
335
+ fi
336
+ # ╔════════════════════════════════════════════════════════════╗
337
+ # β•‘ >>> REMOVE END β€” ONE-TIME MIGRATION FROM OLD BUCKET β•‘
338
+ # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
339
+
340
  hf_restore_saves
341
  echo ""
342