forked from makohn/MessageBoard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_launcher.sh
executable file
·63 lines (55 loc) · 1.48 KB
/
server_launcher.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
#!/bin/bash
BUILD_SCRIPT=build.sh
BUILD_PATH=MessageBoard/build/
SERVER=server.jar
# Check whether java is installed on the system
if type -p java &> /dev/null; then
echo found java executable in PATH
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo found java executable in JAVA_HOME
_java="$JAVA_HOME/bin/java"
else
echo "can't find java. Make sure java is installed."
fi
# Check whether java version is at least 1.8
if [[ "$_java" ]]; then
version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo using java version "$version"
if [[ "$version" < "1.8" ]]; then
echo "please upgrade java to version 1.8"
fi
fi
# Change directory into the build directory
if ! [[ -d "$BUILD_PATH" ]]; then
echo directory $BUILD_PATH does not exist.
echo Make sure you run $BUILD_SCRIPT first.
exit 1
fi
cd $BUILD_PATH
# Check if executable jar exists
if ! [[ -f "$SERVER" ]]; then
echo file $SERVER does not exist.
exit 2
fi
# Try to launch server.jar with given cli args
if [[ $# -gt 1 ]]; then
java -jar $SERVER $@
else
printf "Do you want to start a root server? (Y/n): "
read root
printf "Groupname: "
read GROUP
printf "Port: "
read PORT
if [[ $root == "Y" ]]; then
java -jar $SERVER -g $GROUP -p $PORT
else
printf "IP address of parent: "
read PARENT_IP
printf "Groupname of parent: "
read PARENT_GROUP
java -jar $SERVER -g $GROUP -p $PORT -ph $PARENT_IP -pg $PARENT_GROUP
fi
fi
exit 0