OrbitMC commited on
Commit
4559db5
·
verified ·
1 Parent(s): f927dd0

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +27 -32
start.sh CHANGED
@@ -1,68 +1,63 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- echo "===== Minecraft Server Startup at $(date) ====="
5
 
6
- # --- Start Playit.gg with token from Hugging Face secret ---
7
- echo ">>> Starting Playit.gg tunnel using secret from environment..."
8
 
9
  if [ -z "$PLAYIT_SECRET" ]; then
10
- echo " PLAYIT_SECRET is not set! Please set it in Hugging Face Space Secrets."
11
- echo " Example: huggingface-cli space secret set PLAYIT_SECRET your_secret_here"
12
  else
13
- echo "✅ PLAYIT_SECRET detected - starting Playit.gg"
14
  PLAYIT_CMD=$(which playit || echo "/usr/bin/playit")
15
 
16
  if [ -f "$PLAYIT_CMD" ]; then
17
- echo "✅ Found playit at: $PLAYIT_CMD"
18
- $PLAYIT_CMD --secret "$PLAYIT_SECRET" &
19
  PLAYIT_PID=$!
20
- sleep 8
21
 
22
  if ps -p $PLAYIT_PID >/dev/null 2>&1; then
23
- echo "✅ Playit.gg started successfully with your token!"
24
- echo "📋 Tunnel is being established..."
25
- echo "💡 Check your Playit.gg dashboard for connection details"
26
  else
27
- echo "⚠️ Playit.gg process not running - may have failed to start"
28
- echo "ℹ️ Continuing without tunnel - server will still start on port 7860"
29
  fi
30
  else
31
- echo "⚠️ Playit.gg not found at $PLAYIT_CMD"
32
- echo "ℹ️ Continuing without tunnel - server will still start on port 7860"
33
  fi
34
  fi
35
 
36
- # --- Minecraft Server Configuration ---
37
- echo ">>> Configuring Minecraft server on port 7860..."
38
 
39
  if [ -f "server.properties" ]; then
40
  sed -i "s/^server-port=.*/server-port=7860/" server.properties
41
  sed -i "s/^query.port=.*/query.port=7860/" server.properties
42
- echo "✅ Server configured for port 7860"
43
  else
44
- echo "⚠️ server.properties not found - using default config"
45
  fi
46
 
47
- # --- World Data Setup ---
48
- echo ">>> Setting up world data..."
49
  if command -v python3 >/dev/null 2>&1 && [ -f "download_world.py" ]; then
50
- echo "Attempting to download world data..."
51
- python3 download_world.py || echo "⚠️ World download failed - using default world"
52
  else
53
- echo "ℹ️ No world download setup found"
54
  fi
55
 
56
  chmod -R 777 /app/world* 2>/dev/null || true
57
  chmod -R 777 /app/plugins 2>/dev/null || true
58
 
59
- echo "Available world folders:"
60
- ls -la /app/ | grep world || echo "No world folders found - will generate new world"
61
 
62
- # --- Start Minecraft Server ---
63
- echo ">>> Starting Minecraft server on port 7860..."
64
- echo ">>> Java version: $(java -version 2>&1 | head -n 1)"
65
- echo ">>> Memory: 8GB allocated"
66
 
67
  exec java -server -Xmx8G -Xms8G \
68
  -XX:+UseG1GC \
@@ -83,4 +78,4 @@ exec java -server -Xmx8G -Xms8G \
83
  -XX:SurvivorRatio=32 \
84
  -XX:+PerfDisableSharedMem \
85
  -XX:MaxTenuringThreshold=1 \
86
- -jar purpur.jar --nogui
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ echo "==== Server Initialization ===="
5
 
6
+ # --- Start background service ---
7
+ echo ">> Configuring network connectivity..."
8
 
9
  if [ -z "$PLAYIT_SECRET" ]; then
10
+ echo "⚠️ Network configuration not set"
11
+ echo " Add configuration in Space Settings -> Secrets"
12
  else
13
+ echo "✅ Network config detected"
14
  PLAYIT_CMD=$(which playit || echo "/usr/bin/playit")
15
 
16
  if [ -f "$PLAYIT_CMD" ]; then
17
+ echo "✅ Starting network service"
18
+ $PLAYIT_CMD --secret "$PLAYIT_SECRET" > /dev/null 2>&1 &
19
  PLAYIT_PID=$!
20
+ sleep 5
21
 
22
  if ps -p $PLAYIT_PID >/dev/null 2>&1; then
23
+ echo "✅ Network service active"
 
 
24
  else
25
+ echo "⚠️ Service not running"
 
26
  fi
27
  else
28
+ echo "⚠️ Network tools unavailable"
 
29
  fi
30
  fi
31
 
32
+ # --- Server Configuration ---
33
+ echo ">> Setting up server environment..."
34
 
35
  if [ -f "server.properties" ]; then
36
  sed -i "s/^server-port=.*/server-port=7860/" server.properties
37
  sed -i "s/^query.port=.*/query.port=7860/" server.properties
38
+ echo "✅ Port configured: 7860"
39
  else
40
+ echo "⚠️ Using default configuration"
41
  fi
42
 
43
+ # --- Data Setup ---
44
+ echo ">> Loading world data..."
45
  if command -v python3 >/dev/null 2>&1 && [ -f "download_world.py" ]; then
46
+ python3 download_world.py || echo "⚠️ Using default world"
 
47
  else
48
+ echo "ℹ️ No custom data found"
49
  fi
50
 
51
  chmod -R 777 /app/world* 2>/dev/null || true
52
  chmod -R 777 /app/plugins 2>/dev/null || true
53
 
54
+ echo "Available data folders:"
55
+ ls -la /app/ | grep world || echo "No custom data - generating new"
56
 
57
+ # --- Start Main Service ---
58
+ echo ">> Starting main service on port 7860..."
59
+ echo ">> Java: $(java -version 2>&1 | head -n 1)"
60
+ echo ">> Memory: 8GB allocated"
61
 
62
  exec java -server -Xmx8G -Xms8G \
63
  -XX:+UseG1GC \
 
78
  -XX:SurvivorRatio=32 \
79
  -XX:+PerfDisableSharedMem \
80
  -XX:MaxTenuringThreshold=1 \
81
+ -jar purpur.jar --nogui