Skip to content

Instantly share code, notes, and snippets.

@Josakko
Created October 31, 2025 19:27
Show Gist options
  • Select an option

  • Save Josakko/61002da3ca4d30e6e6e35df09e678045 to your computer and use it in GitHub Desktop.

Select an option

Save Josakko/61002da3ca4d30e6e6e35df09e678045 to your computer and use it in GitHub Desktop.
mincraft server wrapper script
#!/bin/bash
ram='8G'
java_args=( )
file='server.jar'
args=( '--nogui' "$@" )
java='java'
# debug
# echo "${args[@]}"
#
# echo "RUNNING WITH: ${java} -Xms${ram} -Xmx${ram} ${java_args[*]} -jar ${file} ${args[*]} "
while true; do
printf '\e[0;32mStarting server...\e[0m \n'
"${java}" -Xms"${ram}" -Xmx"${ram}" "${java_args[@]}" -jar "${file}" "${args[@]}"
for i in {3..1}; do
printf '\e[0;33mServer restarting in %s... (CTRL-C to exit) \e[0m \n' "$i"
sleep 1
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment