-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-server.sh
executable file
·96 lines (78 loc) · 2.67 KB
/
run-server.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
if [ ! -d "build" ]; then
echo "Spigot is not downloaded, downloading and building now.."
rm -rf build/
mkdir build
cd build
curl -O https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev 1.10
if [ ! -d "apache-maven-3.2.5" ]; then
echo "Maven is not downloaded, downloading now.."
curl -o apache-maven-3.2.5.zip http://mirror.metrocast.net/apache//maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip
unzip apache-maven-3.2.5.zip
rm apache-maven-3.2.5.zip
fi
cd ..
chmod +x ./build/apache-maven-3.2.5/bin/mvn # for some reason this isn't executable by default..
fi
if [ ! -d "server/plugins" ]; then
mkdir -p server/plugins
fi
if [ ! -f "server/spigot.jar" ]; then
cp build/spigot-1.10.2.jar server/spigot.jar
fi
if [ ! -f "server/eula.txt" ]; then
read -p "Do you accept the Mojang EULA? If not, then exit the program now. Otherwise, press Enter."
echo "eula=true" > server/eula.txt
fi
_term() {
echo "stop" > /tmp/srv-input
exit
}
if [[ ! $(uname) == MING* ]]; then
trap _term EXIT # only trap exit event if we're on unix
fi
while true; do
if [ -f "build/apache-maven-3.2.5" ]; then
./build/apache-maven-3.2.5/bin/mvn clean install # use the maven that spigot build tools downloaded
else
mvn clean install
fi
cp target/DevathonProject-1.0-SNAPSHOT.jar server/plugins/DevathonProject-1.0-SNAPSHOT.jar
cd server
if [[ $(uname) == MING* ]]; then
# we're running inside of git bash on windows, which doesn't support everything that unix systems do
# so just run the jar and ask the user if they want to continue running after it's done
java -jar spigot.jar
read -n 1 -p "Do you want to recompile and restart the server? (y/n) " value
if [ "$value" == "n" ]; then
echo "Shutting down process.."
exit
fi
else
# set up out process
rm -f /tmp/srv-input
mkfifo /tmp/srv-input
cat > /tmp/srv-input &
tail -f /tmp/srv-input | java -jar spigot.jar &
running=true
while $running; do
read input
if [ "$input" == "stop" ]; then
running=false
echo "stop" > /tmp/srv-input
elif [ "$input" == "exit" ]; then
running=false
echo "stop" > /tmp/srv-input
sleep 2
exit
else
echo "$input" > /tmp/srv-input
fi
sleep 1
done
fi
cd ..
echo "Rebuilding project.."
sleep 1
done