Updated Usage function
This commit is contained in:
parent
ba6ca6e2c2
commit
4ce9c4031b
@ -9,7 +9,7 @@ MAX_MEM=8
|
|||||||
INITIAL_MEM=2
|
INITIAL_MEM=2
|
||||||
|
|
||||||
#rcon password
|
#rcon password
|
||||||
DEFAULT_RCON_PASSWORD=""
|
DEFAULT_RCON_PASSWORD="bqMLwxCJKRktrQoir2pg4KkTeBDQLjb4C+RYesdmeKF4sie8"
|
||||||
|
|
||||||
echo_rgb() {
|
echo_rgb() {
|
||||||
# Echo a colored string to the terminal based on rgb values
|
# Echo a colored string to the terminal based on rgb values
|
||||||
@ -164,19 +164,27 @@ usage() {
|
|||||||
# POSIX Compliant:
|
# POSIX Compliant:
|
||||||
# Yes
|
# Yes
|
||||||
#
|
#
|
||||||
printf "Usage: %s%s\n" \
|
printf "Usage: %s\n" \
|
||||||
"$(basename ${0}) " \
|
"$(basename "${0}") -s <server id> | $(basename "${0}") -s <server id> -r | $(basename "${0}") -s <server id> -j <path/to/minecraft/jar>
|
||||||
"
|
--server <server id> -s <server id>
|
||||||
-i \"this is some input\" -t \"this is some more example input\"
|
Which minecraft server to start, see the ~/Minecraft directory -- each number corresponds to an ID
|
||||||
--input <string> | -i <string>
|
|
||||||
Example:
|
Example:
|
||||||
--input \"this is an example input\"
|
--server 1
|
||||||
--test <string> | -t <string>
|
--r | --rcon-ignore
|
||||||
|
Flag that takes no parameters -- when enabled this script will not overwrite the RCON password in the targeted server
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
--test \"this is more example input\""
|
--rcon-ignore
|
||||||
|
--jar <path/to/mc/server/jar/file> | -j <path/to/mc/server/jar/file>
|
||||||
|
Takes in a path to a minecraft server jar file. It copies that file to create the new server
|
||||||
|
|
||||||
|
Example:
|
||||||
|
--jar ~/Minecraft-Server-Jars/minecraft_server1.17.1.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
server_id=""
|
server_id=""
|
||||||
minecraft_jar=""
|
minecraft_jar=""
|
||||||
rcon_ignore=0
|
rcon_ignore=0
|
||||||
@ -235,16 +243,20 @@ parse_args "$@"
|
|||||||
|
|
||||||
minecraft_directory=~/Minecraft/Server-"${server_id}"
|
minecraft_directory=~/Minecraft/Server-"${server_id}"
|
||||||
|
|
||||||
mkdir -p "${minecraft_directory}"
|
create_directories() {
|
||||||
mkdir -p "${minecraft_directory}/backups"
|
mkdir -p "${minecraft_directory}"
|
||||||
|
mkdir -p "${minecraft_directory}/backups"
|
||||||
|
cd "${minecraft_directory}" || (log "error" "Unable to change directory to ${minecraft_directory}" && exit 1)
|
||||||
|
}
|
||||||
|
|
||||||
cd "${minecraft_directory}" || (log "error" "Unable to change directory to ${minecraft_directory}" && exit 1)
|
create_directories
|
||||||
|
|
||||||
if [ -n "${minecraft_jar}" ]; then
|
if [ -n "${minecraft_jar}" ]; then
|
||||||
if [ ! -f "${minecraft_jar}" ]; then
|
if [ ! -f "${minecraft_jar}" ]; then
|
||||||
log "error" "Could not find a minecraft server jar \"${minecraft_jar}\""
|
log "error" "Could not find a minecraft server jar \"${minecraft_jar}\""
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
minecraft_jar_name="$(basename "${minecraft_jar}")"
|
minecraft_jar_name="$(basename "${minecraft_jar}")"
|
||||||
log "info" "Copying minecraft server files..."
|
log "info" "Copying minecraft server files..."
|
||||||
cp "${minecraft_jar}" "${minecraft_directory}" \
|
cp "${minecraft_jar}" "${minecraft_directory}" \
|
||||||
@ -253,8 +265,8 @@ if [ -n "${minecraft_jar}" ]; then
|
|||||||
log "info" "Installed a minecraft server.jar to Minecraft-Server-${server_id}"
|
log "info" "Installed a minecraft server.jar to Minecraft-Server-${server_id}"
|
||||||
java -jar "${minecraft_directory}"/server.jar > /dev/null 2>&1
|
java -jar "${minecraft_directory}"/server.jar > /dev/null 2>&1
|
||||||
log "info" "Successfully installed the minecraft server.jar to Minecraft-Server-${server_id}, continuing with setup"
|
log "info" "Successfully installed the minecraft server.jar to Minecraft-Server-${server_id}, continuing with setup"
|
||||||
elif [ ! -d "${minecraft_directory}" ]; then
|
elif [ ! -f "${minecraft_directory}"/server.jar ]; then
|
||||||
log "error" "The minecraft server \"${minecraft_directory}\" did not exist, to create it please pass the \"--jar\" flag..."
|
log "error" "No server.jar found within ${minecraft_directory}, to create a new server there use the \"--jar\" flag"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -326,4 +338,8 @@ log "info" "Starting Minecraft-Server-${server_id}"
|
|||||||
tmux new-session -d -s \
|
tmux new-session -d -s \
|
||||||
"Minecraft-Server-${server_id}" \
|
"Minecraft-Server-${server_id}" \
|
||||||
java -Xms"${INITIAL_MEM}G" -Xmx"${MAX_MEM}G" -jar server.jar --nogui \
|
java -Xms"${INITIAL_MEM}G" -Xmx"${MAX_MEM}G" -jar server.jar --nogui \
|
||||||
&& log "info" "Server Minecraft-Server-${server_id} started successfully!"
|
&& log "info" \
|
||||||
|
"Server Minecraft-Server-${server_id} started successfully:
|
||||||
|
Game Port: ${server_port}
|
||||||
|
Query Port: ${query_port}
|
||||||
|
RCON Port: ${rcon_port}"
|
||||||
|
Loading…
Reference in New Issue
Block a user