Add sleep parameter to start.sh
This commit is contained in:
parent
b9e82b96e3
commit
61cb39b414
@ -61,7 +61,7 @@ function main {
|
|||||||
"--quiet" | "-q")
|
"--quiet" | "-q")
|
||||||
quiet=true
|
quiet=true
|
||||||
;;
|
;;
|
||||||
"--help")
|
"--help" | "-h")
|
||||||
help=true
|
help=true
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -81,9 +81,9 @@ function main {
|
|||||||
echo " standalone"
|
echo " standalone"
|
||||||
echo ""
|
echo ""
|
||||||
echo "OPTIONS:"
|
echo "OPTIONS:"
|
||||||
echo " --fetch - print the current mode before reconfiguring the server. Nothing else will be printed."
|
echo " --fetch Print the current mode before reconfiguring the server. Nothing else will be printed."
|
||||||
echo " --help - show this message"
|
echo " -h --help Show this message"
|
||||||
echo " -q --quiet - Dont print any output, except for output which is caused by --fetch"
|
echo " -q --quiet Don't print any output, except for output which is caused by --fetch"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
84
start.sh
84
start.sh
@ -1,46 +1,63 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# THe name of the screen in which the proxy server will run
|
||||||
PROXY_SCREEN="proxy"
|
PROXY_SCREEN="proxy"
|
||||||
|
# How many seconds to sleep before starting the server again, unless it is explicitly specified
|
||||||
|
DEFAULT_SLEEP_SECONDS=3
|
||||||
|
|
||||||
proxy=false
|
function main {
|
||||||
bungee=false
|
local proxy=false
|
||||||
help=false
|
local bungee=false
|
||||||
|
local help=false
|
||||||
|
local sleep_seconds=$DEFAULT_SLEEP_SECONDS
|
||||||
|
|
||||||
for arg in "$@"; do
|
local cmd=$0
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
local arg=$1
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
|
"--sleep" | "-s")
|
||||||
|
sleep_seconds=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
"--proxy")
|
"--proxy")
|
||||||
proxy=true
|
proxy=true
|
||||||
if $bungee; then
|
if $bungee; then
|
||||||
echo "--proxy can't be used together with --bungee"
|
err "--proxy can't be used together with --bungee"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"--bungee")
|
"--bungee")
|
||||||
bungee=true
|
bungee=true
|
||||||
if $proxy; then
|
if $proxy; then
|
||||||
echo "--bungee can't be used together with --proxy"
|
err "--bungee can't be used together with --proxy"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
"--help")
|
"--help" | "-h")
|
||||||
help=true
|
help=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown argument. Use --help to see all options"
|
err "Unknown argument: $arg"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if $help; then
|
if $help; then
|
||||||
echo "Create a start loop for the minecraft server, additionally behind a velocity proxy or bungeecord proxy"
|
echo "Create a start loop for the minecraft server, additionally behind a velocity proxy or bungeecord proxy"
|
||||||
echo "--help Show help"
|
echo ""
|
||||||
echo "--proxy Start the server behind a velocity proxy"
|
echo "Usage $cmd [OPTIONS]"
|
||||||
echo "--bungee Start the server behind a bungeecord proxy"
|
echo ""
|
||||||
|
echo "OPTIONS:"
|
||||||
|
echo " -s --sleep How many seconds to sleep after the server has stopped before starting it again"
|
||||||
|
echo " -h --help Show help"
|
||||||
|
echo " --proxy Start the server behind a velocity proxy"
|
||||||
|
echo " --bungee Start the server behind a bungeecord proxy"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $proxy; then
|
if $proxy; then
|
||||||
./configure.sh velocity
|
./configure.sh velocity
|
||||||
|
|
||||||
# create proxy screen if it doesn't exist yet
|
# create proxy screen if it doesn't exist yet
|
||||||
@ -49,7 +66,7 @@ if $proxy; then
|
|||||||
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/proxy; ./launch.sh\n"
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/proxy; ./launch.sh\n"
|
||||||
|
|
||||||
echo "The velocity proxy has been started in the screen '$PROXY_SCREEN'"
|
echo "The velocity proxy has been started in the screen '$PROXY_SCREEN'"
|
||||||
elif $bungee; then
|
elif $bungee; then
|
||||||
./configure.sh bungeecord
|
./configure.sh bungeecord
|
||||||
|
|
||||||
# create proxy screen if it doesn't exist yet
|
# create proxy screen if it doesn't exist yet
|
||||||
@ -58,13 +75,13 @@ elif $bungee; then
|
|||||||
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/bungee; ./launch.sh\n"
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/bungee; ./launch.sh\n"
|
||||||
|
|
||||||
echo "The bungeecord proxy has been started in the screen '$PROXY_SCREEN'"
|
echo "The bungeecord proxy has been started in the screen '$PROXY_SCREEN'"
|
||||||
else
|
else
|
||||||
./configure.sh standalone
|
./configure.sh standalone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap cleanup SIGINT
|
trap cleanup SIGINT
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
if $proxy || $bungee; then
|
if $proxy || $bungee; then
|
||||||
# stop the proxy
|
# stop the proxy
|
||||||
screen -S "$PROXY_SCREEN" -X stuff "end\n"
|
screen -S "$PROXY_SCREEN" -X stuff "end\n"
|
||||||
@ -72,15 +89,26 @@ cleanup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo starting server...
|
echo starting server...
|
||||||
./launch.sh
|
./launch.sh
|
||||||
echo sleeping...
|
echo sleeping...
|
||||||
sleep 3
|
sleep "$sleep_seconds"
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shows ans error message and exits the program with code 1
|
||||||
|
#
|
||||||
|
# Usage: err <msg>
|
||||||
|
function err {
|
||||||
|
echo "$1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user