88 lines
1.8 KiB
Bash
Executable File
88 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
PROXY_SCREEN="proxy"
|
|
|
|
proxy=false
|
|
bungee=false
|
|
help=false
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
"--proxy")
|
|
proxy=true
|
|
if $bungee; then
|
|
echo "--proxy can't be used together with --bungee"
|
|
exit 1
|
|
fi
|
|
;;
|
|
"--bungee")
|
|
bungee=true
|
|
if $proxy; then
|
|
echo "--bungee can't be used together with --proxy"
|
|
exit 1
|
|
fi
|
|
;;
|
|
"--help")
|
|
help=true
|
|
;;
|
|
*)
|
|
echo "Unknown argument. Use --help to see all options"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if $help; then
|
|
echo "Create a start loop for the minecraft server, additionally behind a velocity proxy or bungeecord proxy"
|
|
echo "--help Show help"
|
|
echo "--proxy Start the server behind a velocity proxy"
|
|
echo "--bungee Start the server behind a bungeecord proxy"
|
|
exit
|
|
fi
|
|
|
|
if $proxy; then
|
|
./configure.sh velocity
|
|
|
|
# create proxy screen if it doesn't exist yet
|
|
screen -ls | grep -q "$PROXY_SCREEN" || screen -dmS "$PROXY_SCREEN"
|
|
# start the proxy
|
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/proxy; ./launch.sh\n"
|
|
|
|
echo "The velocity proxy has been started in the screen '$PROXY_SCREEN'"
|
|
elif $bungee; then
|
|
./configure.sh bungeecord
|
|
|
|
# create proxy screen if it doesn't exist yet
|
|
screen -ls | grep -q "$PROXY_SCREEN" || screen -dmS "$PROXY_SCREEN"
|
|
# start the proxy
|
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/bungee; ./launch.sh\n"
|
|
|
|
echo "The bungeecord proxy has been started in the screen '$PROXY_SCREEN'"
|
|
else
|
|
./configure.sh standalone
|
|
fi
|
|
|
|
trap cleanup SIGINT
|
|
|
|
cleanup() {
|
|
if $proxy || $bungee; then
|
|
# stop the proxy
|
|
screen -S "$PROXY_SCREEN" -X stuff "end\n"
|
|
echo "The proxy has been stopped"
|
|
fi
|
|
|
|
exit
|
|
}
|
|
|
|
while true
|
|
do
|
|
echo starting server...
|
|
./launch.sh
|
|
echo sleeping...
|
|
sleep 3
|
|
done
|
|
|
|
|
|
|
|
|