Compare commits
No commits in common. "c870aae9dad236e6caa4c57564d70b0c670428fe" and "3e0ace43d2e47dca4c4aee0336ca5765c6f219bd" have entirely different histories.
c870aae9da
...
3e0ace43d2
102
start.sh
102
start.sh
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
# THe name of the screen in which the proxy server will run
|
# THe name of the screen in which the proxy server will run
|
||||||
PROXY_SCREEN="proxy"
|
PROXY_SCREEN="proxy"
|
||||||
# The relative path of the velocity proxy server
|
|
||||||
VELOCITY_DIR="proxy"
|
|
||||||
# The relative path of the bungeecord proxy server
|
|
||||||
BUNGEE_DIR="bungee"
|
|
||||||
# How many seconds to sleep before starting the server again, unless it is explicitly specified
|
# How many seconds to sleep before starting the server again, unless it is explicitly specified
|
||||||
DEFAULT_SLEEP_SECONDS=3
|
DEFAULT_SLEEP_SECONDS=3
|
||||||
|
|
||||||
@ -15,43 +11,17 @@ function main {
|
|||||||
local help=false
|
local help=false
|
||||||
local sleep_seconds=$DEFAULT_SLEEP_SECONDS
|
local sleep_seconds=$DEFAULT_SLEEP_SECONDS
|
||||||
local config=""
|
local config=""
|
||||||
local start_proxy=false
|
|
||||||
local tmp=false
|
|
||||||
|
|
||||||
local cmd=$0
|
local cmd=$0
|
||||||
|
|
||||||
# Parse arguments
|
# TODO --config is incompatible with --proxy, --bungee and standalone
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
local arg=$1
|
local arg=$1
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--config" | "-c")
|
"--config" | "-c")
|
||||||
local mode=$2
|
config=$2 #TODO ensure mode is valid
|
||||||
case "$mode" in
|
|
||||||
"proxy")
|
|
||||||
config="velocity"
|
|
||||||
;;
|
|
||||||
"bungee")
|
|
||||||
config="bungeecord"
|
|
||||||
;;
|
|
||||||
"standalone")
|
|
||||||
config="standalone"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
err "Invalid mode for --config: $mode"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if $proxy; then
|
|
||||||
err "--config can't be used together with --proxy"
|
|
||||||
elif $bungee; then
|
|
||||||
err "--config can't be used together with --bungee"
|
|
||||||
fi
|
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
"--temp" | "--tmp" | "-t")
|
|
||||||
tmp=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
"--sleep" | "-s")
|
"--sleep" | "-s")
|
||||||
sleep_seconds=$2
|
sleep_seconds=$2
|
||||||
shift 2
|
shift 2
|
||||||
@ -60,8 +30,6 @@ function main {
|
|||||||
proxy=true
|
proxy=true
|
||||||
if $bungee; then
|
if $bungee; then
|
||||||
err "--proxy can't be used together with --bungee"
|
err "--proxy can't be used together with --bungee"
|
||||||
elif [[ -n $config ]]; then
|
|
||||||
err "--proxy can't be used together with --config"
|
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -69,8 +37,6 @@ function main {
|
|||||||
bungee=true
|
bungee=true
|
||||||
if $proxy; then
|
if $proxy; then
|
||||||
err "--bungee can't be used together with --proxy"
|
err "--bungee can't be used together with --proxy"
|
||||||
elif [[ -n $config ]]; then
|
|
||||||
err "--bungee can't be used together with --config"
|
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -84,20 +50,6 @@ function main {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Late parsing:
|
|
||||||
if $tmp && [[ -z $config ]]; then
|
|
||||||
err "--temp requires --config parameter"
|
|
||||||
fi
|
|
||||||
if $proxy; then
|
|
||||||
start_proxy=true
|
|
||||||
config="velocity"
|
|
||||||
tmp=true
|
|
||||||
elif $bungee; then
|
|
||||||
start_proxy=true
|
|
||||||
config="bungeecord"
|
|
||||||
tmp=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
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 ""
|
echo ""
|
||||||
@ -105,7 +57,6 @@ function main {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "OPTIONS:"
|
echo "OPTIONS:"
|
||||||
echo " -c --config <mode> How to configure the server. Possible values for mode are: proxy, bungee, standalone"
|
echo " -c --config <mode> How to configure the server. Possible values for mode are: proxy, bungee, standalone"
|
||||||
echo " -t --temp --tmp Apply the configuration only temporary, while the server is running. Requires --config."
|
|
||||||
echo " -s --sleep <secs> How many seconds to sleep after the server has stopped before starting it again"
|
echo " -s --sleep <secs> How many seconds to sleep after the server has stopped before starting it again"
|
||||||
echo " -h --help Show help"
|
echo " -h --help Show help"
|
||||||
echo " --proxy Start the server behind a velocity proxy"
|
echo " --proxy Start the server behind a velocity proxy"
|
||||||
@ -113,45 +64,42 @@ function main {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply configuration
|
# TODO perform configuration according to config parameter
|
||||||
local previous_config=""
|
|
||||||
if [[ -n $config ]]; then
|
if $proxy; then
|
||||||
previous_config=$(./configure.sh "$config" --fetch)
|
./configure.sh velocity
|
||||||
fi
|
|
||||||
|
|
||||||
# Start proxy
|
|
||||||
if $start_proxy; then
|
|
||||||
# create proxy screen if it doesn't exist yet
|
# create proxy screen if it doesn't exist yet
|
||||||
screen -ls | grep -q "$PROXY_SCREEN" || screen -dmS "$PROXY_SCREEN"
|
screen -ls | grep -q "$PROXY_SCREEN" || screen -dmS "$PROXY_SCREEN"
|
||||||
# start the proxy
|
# start the proxy
|
||||||
local proxy_dir="$(pwd)/proxy"
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/proxy; ./launch.sh\n"
|
||||||
case "$config" in
|
|
||||||
"velocity")
|
echo "The velocity proxy has been started in the screen '$PROXY_SCREEN'"
|
||||||
proxy_dir=$VELOCITY_DIR
|
elif $bungee; then
|
||||||
;;
|
./configure.sh bungeecord
|
||||||
"bungeecord")
|
|
||||||
proxy_dir=$BUNGEE_DIR
|
# create proxy screen if it doesn't exist yet
|
||||||
;;
|
screen -ls | grep -q "$PROXY_SCREEN" || screen -dmS "$PROXY_SCREEN"
|
||||||
esac
|
# start the proxy
|
||||||
screen -S "$PROXY_SCREEN" -X stuff "cd $proxy_dir; ./launch.sh\n"
|
screen -S "$PROXY_SCREEN" -X stuff "cd $(pwd)/bungee; ./launch.sh\n"
|
||||||
echo "The proxy has been started in screen $PROXY_SCREEN"
|
|
||||||
|
echo "The bungeecord proxy has been started in the screen '$PROXY_SCREEN'"
|
||||||
|
else
|
||||||
|
./configure.sh standalone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function cleanup {
|
trap cleanup SIGINT
|
||||||
if $start_proxy; then
|
|
||||||
|
cleanup() {
|
||||||
|
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"
|
||||||
echo "The proxy has been stopped"
|
echo "The proxy has been stopped"
|
||||||
fi
|
fi
|
||||||
if $tmp; then
|
|
||||||
./configure.sh "$previous_config"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup SIGINT
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo starting server...
|
echo starting server...
|
||||||
@ -161,7 +109,7 @@ function main {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shows an error message and exits the program with code 1
|
# Shows ans error message and exits the program with code 1
|
||||||
#
|
#
|
||||||
# Usage: err <msg>
|
# Usage: err <msg>
|
||||||
function err {
|
function err {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user