nazib61 commited on
Commit
d824a5a
·
verified ·
1 Parent(s): 9ff2555

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +16 -46
start.sh CHANGED
@@ -1,54 +1,24 @@
1
  #!/bin/bash
2
- set -euo pipefail
3
 
4
- # ensure writable
5
- chmod -R a+rwx /server || true
6
- cd /server
7
 
8
- # ---------- start playit agent in background ----------
9
- PLAYIT_LOG=/tmp/playit.log
10
- rm -f "$PLAYIT_LOG"
11
-
12
- if [ -x ./playit ]; then
13
- echo "[INFO] Starting playit agent..."
14
- ./playit > "$PLAYIT_LOG" 2>&1 &
15
-
16
- # wait for a claim url to appear (max 120s)
17
- CLAIM_URL=""
18
- for i in $(seq 1 24); do
19
- sleep 5
20
- CLAIM_URL=$(grep -Eo 'https://playit.gg/claim/[A-Za-z0-9_-]+' "$PLAYIT_LOG" | head -1 || true)
21
- if [ -n "$CLAIM_URL" ]; then break; fi
22
- # also some versions print "Your claim code is:" style - try to show entire log head
23
- done
24
-
25
- if [ -n "$CLAIM_URL" ]; then
26
- echo "[ACTION] Open this claim URL in your browser to add the agent to your playit account:"
27
- echo "$CLAIM_URL"
28
- echo "[INFO] After you claim the agent, go to playit.gg dashboard -> Add Tunnel -> select Local Port 25565 (TCP) to create a public address."
29
- else
30
- echo "----- playit agent log (first 200 lines) -----"
31
- sed -n '1,200p' "$PLAYIT_LOG" || true
32
- echo "----- end log -----"
33
- echo "[INFO] If you don't see a claim URL, open the playit log above and look for a '/claim/' link. You can also run the agent locally once to claim and then reuse the config."
34
- fi
35
- else
36
- echo "[WARN] playit binary not found or not executable."
37
- fi
38
-
39
- # ---------- start Minecraft server regardless ----------
40
- echo "[INFO] Starting Minecraft server (server.jar). Even if playit not claimed yet, server runs locally inside container."
41
- java -Xmx2G -Xms2G -jar server.jar nogui --nogui
42
- # server.properties ফাইলটা আগে থেকেই থাকলে edit করব, না থাকলে বানাবো
43
  if [ ! -f server.properties ]; then
44
- echo "eula=true" > eula.txt
45
- echo "max-tick-time=-1" > server.properties
46
- echo "server-port=25565" >> server.properties
47
- echo "online-mode=false" >> server.properties
 
 
 
 
 
 
48
  fi
49
 
50
- # পুরানো server.properties থাকলেও max-tick-time override কর
51
- sed -i 's/^max-tick-time=.*/max-tick-time=-1/' server.properties || echo "max-tick-time=-1" >> server.properties
52
 
53
- # Minecraft server চালু করা
54
  java -Xmx2G -Xms2G -jar server.jar nogui
 
1
  #!/bin/bash
 
2
 
3
+ # EULA accept
4
+ echo "eula=true" > eula.txt
 
5
 
6
+ # server.properties তৈরি / update
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  if [ ! -f server.properties ]; then
8
+ cat <<EOL > server.properties
9
+ max-tick-time=-1
10
+ server-port=25565
11
+ online-mode=false
12
+ EOL
13
+ else
14
+ # যদি file already থাকে, max-tick-time override করো
15
+ grep -q "max-tick-time" server.properties && \
16
+ sed -i 's/^max-tick-time=.*/max-tick-time=-1/' server.properties || \
17
+ echo "max-tick-time=-1" >> server.properties
18
  fi
19
 
20
+ # Playit agent start (claim URL দেখাে)
21
+ ./playit &
22
 
23
+ # Minecraft server start
24
  java -Xmx2G -Xms2G -jar server.jar nogui