added a todo and added ram allocation option

This commit is contained in:
CerberusV1
2024-10-16 16:24:01 +02:00
parent 73bb7b7f18
commit 2a91755153
2 changed files with 67 additions and 19 deletions

View File

@@ -33,4 +33,5 @@ bash -c "$(curl -sS https://raw.githubusercontent.com/CerberusV1/minecraft_deplo
- Adding check for existing sessions before starting the server - Adding check for existing sessions before starting the server
- Add support for a non-headless session (might not happen) - Add support for a non-headless session (might not happen)
- Adding mod installer from link - Adding mod installer from link
- Adding world import (ideas on how to do that would be appreciated) - Adding world import (ideas on how to do that would be appreciated)
- Adding option to import/export white/blacklist

View File

@@ -19,7 +19,7 @@ PS3=""
while true; do while true; do
clear clear
# Lists all the Options available in the script # Lists all the Options available in the script
options=("Start Server" "Connect to Server" "Set EULA" "Set RAM" "Install Mods" "Exit") options=("Start Server" "Connect to Server" "Set EULA" "Set RAM" "Install Mods" "Exit")
echo " ServerManager" echo " ServerManager"
echo "----------------------------------------------" echo "----------------------------------------------"
# Selects an option from a list and executes it # Selects an option from a list and executes it
@@ -31,10 +31,10 @@ while true; do
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
# Promting before actually starting the server # Promting before actually starting the server
read -p "Do you want to start the server? [y/n] " start_answer read -p "Do you want to start the server? [y/n] " start_answer
# Checks if the EULA file exists # Checks if the EULA file exists
if [[ ${start_answer} == "y" ]]; then if [[ ${start_answer} == "y" ]]; then
if [[ -e "${server}/eula.txt" ]]; then if [[ -e "${server}/eula.txt" ]]; then
# Sets the condition, in this case counting how many lines with eula=true exist in the EULA file # Sets the condition, in this case counting how many lines with eula=true exist in the EULA file
condition=$(cat "${server}/eula.txt" | grep -c "eula=true") condition=$(cat "${server}/eula.txt" | grep -c "eula=true")
# If EULA is accepted, start the server # If EULA is accepted, start the server
if [[ ${condition} -eq 1 ]]; then if [[ ${condition} -eq 1 ]]; then
@@ -45,30 +45,30 @@ while true; do
# Starts the server detatched in a new session # Starts the server detatched in a new session
# To check for sessions tmux ls and to reconnect to an existing one tmux a -t session_name # To check for sessions tmux ls and to reconnect to an existing one tmux a -t session_name
tmux new -d -s "${server_name}" "./start_server.sh" tmux new -d -s "${server_name}" "./start_server.sh"
# If EULA is not accepted, tells the user to accept the EULA before # If EULA is not accepted, tells the user to accept the EULA before
elif [[ ${condition} -eq 0 ]]; then elif [[ ${condition} -eq 0 ]]; then
echo "Before starting the server, please accept the EULA" echo "Before starting the server, please accept the EULA"
# An case that should only appear if more than just one EULA entry was made. # An case that should only appear if more than just one EULA entry was made.
# Either commented or not. This should be easily fixed by accepting the EULA again # Either commented or not. This should be easily fixed by accepting the EULA again
# since every action in this menu doesn´t matter if agreed or not, the file gets # since every action in this menu doesn´t matter if agreed or not, the file gets
# overwritten # overwritten
# Using "Set EULA" should fix that # Using "Set EULA" should fix that
else else
echo "Something went wrong, please recreate the EULA" echo "Something went wrong, please recreate the EULA"
fi fi
# Error massage if the EULA file does not exist. Using "Set EULA" should fix that # Error massage if the EULA file does not exist. Using "Set EULA" should fix that
else else
echo "Before starting the server, please accept the EULA" echo "Before starting the server, please accept the EULA"
echo "error - missing file "eula.txt"" echo "error - missing file "eula.txt""
fi fi
# If the user prompts n in the server start menu, he returns back to the main menu # If the user prompts n in the server start menu, he returns back to the main menu
elif [[ ${start_answer} == "n" ]]; then elif [[ ${start_answer} == "n" ]]; then
break break
# If the user prompts something else than y or n in the server start menu, he returns back to the main menu # If the user prompts something else than y or n in the server start menu, he returns back to the main menu
else else
echo "Invalid input" echo "Invalid input"
break break
fi fi
read -p "Press Enter to return to the menu" read -p "Press Enter to return to the menu"
break break
;; ;;
@@ -100,9 +100,9 @@ while true; do
if [[ ${eula_answer} == "y" ]]; then if [[ ${eula_answer} == "y" ]]; then
echo "# ${current_date}" > "${server}/eula.txt" echo "# ${current_date}" > "${server}/eula.txt"
echo "eula=true" >> "${server}/eula.txt" echo "eula=true" >> "${server}/eula.txt"
# If the user promts no, the EULA gets created/ overwritten and sets it to false. # If the user promts no, the EULA gets created/ overwritten and sets it to false.
# User also gets a reminder that he will not be able to start the server without accepting # User also gets a reminder that he will not be able to start the server without accepting
# to it # to it
elif [[ ${eula_answer} == "n" ]]; then elif [[ ${eula_answer} == "n" ]]; then
echo "# ${current_date}" > "${server}/eula.txt" echo "# ${current_date}" > "${server}/eula.txt"
echo "eula=false" >> "${server}/eula.txt" echo "eula=false" >> "${server}/eula.txt"
@@ -114,12 +114,59 @@ while true; do
break break
;; ;;
"Set RAM") "Set RAM")
echo "Setting RAM..." clear
echo " Allocate RAM "
echo "------------------------------------------------------------"
clear
presets=("1 GB" "2 GB" "4 GB" "8 GB" "16 GB" "Check")
select opt in "${presets[@]}"; do
case $opt in
"1 GB")
echo "Allocate 1GB of RAM"
echo "-Xms512M" > "${server}/user_jvm_args.txt"
echo "-Xmx1G" >> "${server}/user_jvm_args.txt"
break
;;
"2 GB")
echo "Allocate 2GB of RAM"
echo "-Xms1G" > "${server}/user_jvm_args.txt"
echo "-Xmx2G" >> "${server}/user_jvm_args.txt"
break
;;
"4 GB")
echo "Allocate 4GB of RAM"
echo "-Xms2G" > "${server}/user_jvm_args.txt"
echo "-Xmx4G" >> "${server}/user_jvm_args.txt"
break
;;
"8 GB")
echo "Allocate 8GB of RAM"
echo "-Xms4G" > "${server}/user_jvm_args.txt"
echo "-Xmx8G" >> "${server}/user_jvm_args.txt"
break
;;
"16 GB")
echo "Allocate 16GB of RAM"
echo "-Xms8G" > "${server}/user_jvm_args.txt"
echo "-Xmx16G" >> "${server}/user_jvm_args.txt"
break
;;
"Check")
cat "${server}/user_jvm_args.txt"
read -p "Enter"
break
;;
*)
echo "invalid input"
;;
esac
done
read -p "Press Enter to continue..." read -p "Press Enter to continue..."
break break
;; ;;
"Install Mods") "Install Mods")
echo "Installing mods..." clear
echo "Installing mods is not supported yet"
read -p "Press Enter to continue..." read -p "Press Enter to continue..."
break break
;; ;;