forked from debojitsantra/BedrockServerTermux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
56 lines (38 loc) · 813 Bytes
/
run
File metadata and controls
56 lines (38 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
SERVER_DIR="$HOME/server"
START_SCRIPT="start.sh"
USER_STOP=false
trap 'USER_STOP=true' SIGINT
if ! cd "$SERVER_DIR" 2>/dev/null; then
echo "Error: '$SERVER_DIR' not found."
exit 1
fi
if [[ ! -f "$START_SCRIPT" ]]; then
echo "Error: 'start.sh' not found."
exit 1
fi
chmod +x "$START_SCRIPT"
echo " Type 'stop' OR press Ctrl+C to stop"
#watchdog
while true; do
USER_STOP=false
echo "Starting Bedrock server..."
./start.sh
EXIT_CODE=$?
if [[ "$USER_STOP" == true ]]; then
echo
echo "Server stopped by user"
break
fi
if [[ $EXIT_CODE -eq 0 ]]; then
echo
echo "Server stopped by user"
break
fi
# Crash
echo
echo "Server crashed (exit code: $EXIT_CODE)."
echo "Restarting in 5 seconds..."
sleep 5
done