Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
13
.github/FUNDING.yml
vendored
13
.github/FUNDING.yml
vendored
@ -1,13 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: jiriks74 # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
msman-helper.tar.gz
|
@ -5,10 +5,9 @@ function get_existing_server {
|
||||
if ls paper-*.jar 1> /dev/null 2>&1; then
|
||||
existing_server_type="paper"
|
||||
get_existing_paper
|
||||
elif ls fabric-server-mc.*.jar 1> /dev/null 2>&1; then
|
||||
existing_server_type="fabric"
|
||||
get_existing_fabric
|
||||
# TODO: Add support for other server types
|
||||
# elif ls fabric-*.jar 1> /dev/null 2>&1; then
|
||||
# existing_server_type="fabric"
|
||||
# elif ls spigot-*.jar 1> /dev/null 2>&1; then
|
||||
# existing_server_type="spigot"
|
||||
# elif ls craftbukkit-*.jar 1> /dev/null 2>&1; then
|
||||
@ -31,30 +30,6 @@ function get_existing_server {
|
||||
fi
|
||||
}
|
||||
|
||||
# Get existing version and build of fabric
|
||||
function get_existing_fabric {
|
||||
# Get the current server file name
|
||||
server_file=$(basename ./fabric-server-mc.*.jar)
|
||||
|
||||
# Assign the file name to a variable
|
||||
FILE=$server_file
|
||||
|
||||
# Remove the .jar extension
|
||||
FILE=${FILE%.jar}
|
||||
|
||||
# Split by - and get the third field (mc.x.x.x)
|
||||
current_version=$(echo $FILE | cut -d. -f2,3,4 | cut -d- -f1)
|
||||
|
||||
# Split by - and get the fourth field (launcher.x.x.x)
|
||||
current_build=$(echo $FILE | cut -d- -f4 | cut -d. -f2,3,4)
|
||||
|
||||
echo "Current server file: $server_file"
|
||||
echo " - Version $current_version"
|
||||
echo " - Build $current_build"
|
||||
echo
|
||||
echo
|
||||
}
|
||||
|
||||
# Get existing version and build of paper
|
||||
function get_existing_paper {
|
||||
# Get the current server file name
|
@ -86,16 +86,16 @@ function check_script_java {
|
||||
|
||||
# Get the system Java version
|
||||
function check_java_exec {
|
||||
# Check if java is installed
|
||||
if ! command -v java &> /dev/null; then
|
||||
java_version=false
|
||||
else
|
||||
# Get the current Java version and extract the build number
|
||||
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{print $1}')
|
||||
# Check if java is installed
|
||||
if ! command -v java &> /dev/null
|
||||
then
|
||||
java_version=false
|
||||
fi
|
||||
|
||||
if [[ $java_version != $required_java ]]; then
|
||||
java_version=false
|
||||
# If java is installed, get the version (the java_version won't be 0)
|
||||
if [[ $java_version != false ]]; then
|
||||
# Get the current Java version and extract the build number
|
||||
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{print $1}')
|
||||
fi
|
||||
}
|
||||
|
||||
@ -172,11 +172,11 @@ function download_jre {
|
||||
rm java.tar.gz
|
||||
elif [[ $required_java == "16" ]]; then
|
||||
echo "Downloading Java 16"
|
||||
curl -L -o java.tar.gz "https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_$(echo $arch)_linux_hotspot_16.0.2_7.tar.gz"
|
||||
curl -L -o java.tar.gz "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jre_$(echo $arch)_linux_hotspot_16.0.2_7.tar.gz"
|
||||
echo "Extracting Java 16"
|
||||
tar -xzf java.tar.gz
|
||||
echo "Moving Java 16 to $(echo $HOME)/.adoptium_java/jre16"
|
||||
mv jdk-16.0.2+7 "$(echo $HOME)/.adoptium_java/jre16"
|
||||
mv jdk-16.0.2+7-jre "$(echo $HOME)/.adoptium_java/jre16"
|
||||
echo "Removing temporary files"
|
||||
rm java.tar.gz
|
||||
elif [[ $required_java == "17" ]]; then
|
@ -37,9 +37,6 @@ function check_updates {
|
||||
download_build=$latest_build
|
||||
update_version=true
|
||||
update_build=true
|
||||
return
|
||||
else
|
||||
echo Checking for updates...
|
||||
fi
|
||||
|
||||
# Check if $build is empty
|
3
.ms-manager/version.sh
Normal file
3
.ms-manager/version.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXTRA_SCRIPTS_VERSION="v1.0.3"
|
118
.msman/fabric.sh
118
.msman/fabric.sh
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# API URL
|
||||
api_url="https://meta.fabricmc.net/v2/versions/"
|
||||
|
||||
# Example server's jar file name:
|
||||
# fabric-server-mc.1.19.3-loader.0.14.14-launcher.0.11.1.jar
|
||||
|
||||
function check_version_valid {
|
||||
if [[ $(curl -s "$(echo $api_url)/loader/$(echo $version)") == "[]" ]]; then
|
||||
>&2 echo "Error: Invalid version selected: $version"
|
||||
exit 2
|
||||
else
|
||||
# Check if selected build exists
|
||||
if [ ! -z "$build" ]; then
|
||||
if [[ $(curl -s "$(echo $api_url)/loader/$(echo $version)/$(echo $build)") == "\"no loader version found for $(echo $version)\"" ]]; then
|
||||
>&2 echo "Error: Invalid build selected: $build"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function download_server {
|
||||
# Download the server
|
||||
echo "Downloading Fabric server..."
|
||||
echo " - Version $version"
|
||||
echo " - Build $download_build"
|
||||
echo " - Installer $latest_installer"
|
||||
curl "$(echo $api_url)/loader/$(echo $version)/$(echo $download_build)/$(echo $latest_installer)/server/jar" -o "./fabric-server-mc.$(echo $version)-loader.$(echo $download_build)-launcher.$(echo $latest_installer).jar"
|
||||
echo "Download complete."
|
||||
}
|
||||
|
||||
function check_updates {
|
||||
if [[ $server_file == false ]]; then
|
||||
download_build=$latest_build
|
||||
update_version=true
|
||||
update_build=true
|
||||
return
|
||||
else
|
||||
echo Checking for updates...
|
||||
fi
|
||||
|
||||
# Check if $build is empty
|
||||
if [[ -z $build ]]; then
|
||||
# Check if the current version is the same as the one selected
|
||||
if [[ $current_version == $version ]]; then
|
||||
# Check if the current build is the same as the one selected
|
||||
if [[ $current_build == $latest_build ]]; then
|
||||
echo "Server is up to date."
|
||||
else
|
||||
echo "Server is not up to date."
|
||||
download_build=$latest_build
|
||||
update_build=true
|
||||
fi
|
||||
else
|
||||
# Check if $server_file is false
|
||||
ask_version_differs
|
||||
echo "Server is not up to date."
|
||||
download_build=$latest_build
|
||||
update_version=true
|
||||
fi
|
||||
else
|
||||
# Check if the current version is the same as the one selected
|
||||
if [[ $current_version == $version ]]; then
|
||||
# Check if the current build is the same as the one selected
|
||||
if [[ $current_build == $build ]]; then
|
||||
echo "Server is up to date."
|
||||
else
|
||||
echo "Server is not up to date."
|
||||
download_build=$build
|
||||
update_build=true
|
||||
fi
|
||||
else
|
||||
# Check if $server_file is false
|
||||
ask_version_differs
|
||||
echo "Server is not up to date."
|
||||
download_build=$build
|
||||
update_version=true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the latest build number and installer version
|
||||
function get_latest_build {
|
||||
# Get the latest build number
|
||||
latest_build=$(curl -s "$(echo $api_url)/loader/$version" | jq -r '.[0].loader.version')
|
||||
latest_installer=$(curl -s "$(echo $api_url)/installer/" | jq -r '.[0].version')
|
||||
}
|
||||
|
||||
# Check if the server is up to date and update if it isn't
|
||||
function check_and_update {
|
||||
if ! [[ $server_file == false ]]; then
|
||||
echo Checking for updates...
|
||||
fi
|
||||
|
||||
# Get the latest build number
|
||||
get_latest_build
|
||||
|
||||
# Check if the current version is up to date
|
||||
check_updates
|
||||
|
||||
# Check if $build_update is true or $version_update is true
|
||||
if [[ $update_build == true ]] || [[ $update_version == true ]]; then
|
||||
if [[ $server_file != false ]]; then
|
||||
old_server_file=$server_file
|
||||
server_file="fabric-server-mc.$version-loader.$download_build-launcher.$latest_installer.jar"
|
||||
download_server
|
||||
# Delete the old server file
|
||||
delete_old_server
|
||||
else
|
||||
server_file="fabric-server-mc.$version-loader.$download_build-launcher.$latest_installer.jar"
|
||||
download_server
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
echo
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXTRA_SCRIPTS_VERSION="v2.1.6"
|
21
Makefile
21
Makefile
@ -1,21 +0,0 @@
|
||||
# Simple makefile to create a tarball of the msman helper scripts
|
||||
# Turn off verbose mode
|
||||
MAKEFLAGS += -s
|
||||
|
||||
all:
|
||||
CURRENT_SCRIPT_VERSION=`grep "CURRENT_SCRIPT_VERSION=" msman.sh | sed -e "s/CURRENT_SCRIPT_VERSION=//g" | head -n -1`; \
|
||||
EXTRA_VERSION=`grep "EXTRA_SCRIPTS_VERSION=" .msman/version.sh | sed -e "s/EXTRA_SCRIPTS_VERSION=//g"`; \
|
||||
if [ "$$CURRENT_SCRIPT_VERSION" != "$$EXTRA_VERSION" ]; then \
|
||||
echo "ERROR: The version in msman.sh and .msman/version.sh are not the same!"; \
|
||||
echo "ERROR: Please make sure they are the same."; \
|
||||
exit 1; \
|
||||
fi
|
||||
rm -rf msman
|
||||
mkdir msman
|
||||
cp -r .msman msman
|
||||
tar -czf msman-helper.tar.gz msman
|
||||
rm -rf msman
|
||||
|
||||
clean:
|
||||
rm -rf msman
|
||||
rm -f msman-hepler.tar.gz
|
32
README.md
32
README.md
@ -8,7 +8,7 @@ branch.
|
||||
The project grew out of the scope I envisioned at first, surprisingly quickly LOL,
|
||||
so I moved all my development here.
|
||||
|
||||
This project aims to support more Minecraft servers than just paper.
|
||||
This project aims to support more minecraft servers rather than just paper.
|
||||
|
||||
## Features
|
||||
|
||||
@ -16,7 +16,7 @@ This project aims to support more Minecraft servers than just paper.
|
||||
|
||||
- Checks for the correct Java version installed
|
||||
- Enables you to download a download a portable Java version from [Adoptium](https://adoptium.net/)
|
||||
- The script downloads it to `~/.adoptium_java` allowing you to use one
|
||||
- The script download's it to `~/.adoptium_java` allowing you to use one
|
||||
Java downlaod across multiple server instances
|
||||
- It also allows you to use multiple Java versions allowing you to run
|
||||
multiple Minecraft servers requiring different Java versions
|
||||
@ -39,12 +39,11 @@ This project aims to support more Minecraft servers than just paper.
|
||||
|
||||
#### Self-update
|
||||
|
||||
- This script can self-update itself without the need for user intervention
|
||||
- This script can self-update itself without the need for user doing it manually
|
||||
|
||||
## Currently supported servers
|
||||
|
||||
- [Paper](https://papermc.io/)
|
||||
- [Fabric](https://fabricmc.net/use/server/)
|
||||
|
||||
## Dependencies
|
||||
|
||||
@ -66,32 +65,11 @@ you're running something like Ubuntu.*
|
||||
> undefined behavior and may cause the script to crash or perform unexpected actions.
|
||||
>
|
||||
> I strongly advise against making any modifications to the server's `.jar` file
|
||||
> manually, as it may interfere with the functionality of this script.
|
||||
> manually, as it may interfere with the proper functioning of this script.
|
||||
|
||||
## Basic setup
|
||||
|
||||
- Option 1: Oneliner
|
||||
|
||||
```bash
|
||||
curl -sSL "https://raw.githubusercontent.com/jiriks74/msman.sh/main/msman.sh" -o msman.sh && chmod +x msman.sh && ./msman.sh
|
||||
```
|
||||
|
||||
- Option 2: Download `msman.sh` from release to where you want your minecraft
|
||||
server and start it with
|
||||
|
||||
```bash
|
||||
chmod +x msman.sh
|
||||
./msman.sh
|
||||
```
|
||||
|
||||
- Option 2: Clone the repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/jiriks74/msman.sh minecraft_server
|
||||
cd minecraft_server
|
||||
chmod +x msman.sh
|
||||
./msman.sh
|
||||
```
|
||||
- [ ] ***TBD***
|
||||
|
||||
## Updating the server
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#####################################################
|
||||
# Settings for start_papermc.sh script #
|
||||
# Available at https://github.com/jiriks74/msman.sh #
|
||||
#####################################################
|
||||
#############################################################
|
||||
# Settings for start_papermc.sh script #
|
||||
# Available at https://github.com/jiriks74/start_papermc.sh #
|
||||
#############################################################
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
|
||||
# This script is not made for migrating versions. #
|
||||
@ -14,9 +14,7 @@
|
||||
# I am not responsible for any loss of data #
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
|
||||
|
||||
# Supported server types:
|
||||
# - paper
|
||||
# - fabric
|
||||
# Only paper is currently supported
|
||||
server_type="paper"
|
||||
version="1.19.3"
|
||||
# Leave blank to use the latest build (auto updates on every run)
|
||||
@ -40,7 +38,7 @@ mem="6000M"
|
||||
|
||||
# Flags for the server itself
|
||||
# Usefull fot setting rcon password, server port, etc.
|
||||
mc_launchoptions="nogui"
|
||||
mc_launchoptions="-nogui"
|
||||
|
||||
# If you want to get rid of script updates notifications, set the below to false
|
||||
check_for_script_updates=true
|
179
msman.sh
Executable file → Normal file
179
msman.sh
Executable file → Normal file
@ -3,16 +3,16 @@ set -e
|
||||
#############################################################################################################
|
||||
# MinecraftServerMANager #
|
||||
# by jiriks74 #
|
||||
# https://github.com/jiriks74/msman.sh #
|
||||
# https://github.com/jiriks74/start_papermc.sh #
|
||||
# This script is under GPLv3, if you want to distribute changes you have to do so under the same license #
|
||||
# and acknowledge the original script and author. #
|
||||
#############################################################################################################
|
||||
|
||||
CURRENT_SCRIPT_VERSION="v2.1.6"
|
||||
CURRENT_SCRIPT_VERSION="v1.0.3"
|
||||
|
||||
# --------------------------------------------------
|
||||
# You shouldn't need to change anything in this file
|
||||
# Settings are located in 'msman.cfg'
|
||||
# Settings are located in 'launch.cfg'
|
||||
# --------------------------------------------------
|
||||
#
|
||||
# The url of the script (used for updating)
|
||||
@ -107,7 +107,7 @@ function ask_version_differs {
|
||||
echo
|
||||
echo
|
||||
echo "The current server version differs from the one you selected."
|
||||
echo "The server version is $current_version and the selected version is $version."
|
||||
echo "The server version is $current_version and the selected version is $select_version."
|
||||
echo "Do you want to update the server version?"
|
||||
echo "This can cause many issues if you don't know what you are doing."
|
||||
echo
|
||||
@ -132,36 +132,6 @@ function ask_version_differs {
|
||||
fi
|
||||
}
|
||||
|
||||
# Ask if the new server version differs from the old one
|
||||
function ask_server_type_differs {
|
||||
echo
|
||||
echo
|
||||
echo "The current server type differs from the one you selected."
|
||||
echo "The server version is $existing_server_type and the selected type is $server_type."
|
||||
echo "Do you want to change the server type?"
|
||||
echo "This can cause many issues if you don't know what you are doing."
|
||||
echo
|
||||
echo "I am not responsible for any data loss caused by changing the server type."
|
||||
echo
|
||||
echo "You have 15 seconds to respond, or the script will exit"
|
||||
read -t 15 -p "Do you want to change the server type? [y/N] " type_differs
|
||||
|
||||
if [ "$type_differs" != "y" ] && [ "$type_differs" != "Y" ]; then
|
||||
echo "Server type not changed."
|
||||
echo "To start the server again with the server type, change the server type in the config to $existing_server_type."
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ "$type_differs" == "y" ] || [ "$type_differs" == "Y" ]; then
|
||||
read -t 15 -p "Are you sure you want to change the server type? [y/N] " type_differs
|
||||
if [ "$type_differs" != "y" ] && [ "$type_differs" != "Y" ]; then
|
||||
echo "Server type not changed."
|
||||
echo "To start the server again with the server type, change the server type in the config to $existing_server_type."
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Ask if the new server version differs from the old one
|
||||
function ask_server_differs {
|
||||
echo
|
||||
@ -229,36 +199,36 @@ function launch_server {
|
||||
echo "Starting the server..."
|
||||
echo
|
||||
echo
|
||||
java $java_launchoptions -jar $server_file $mc_launchoptions
|
||||
java $java_launchoptions -jar "$(basename ./paper-*.jar)" $mc_launchoptions
|
||||
}
|
||||
|
||||
# Helper scripts update
|
||||
function helper_scripts_update {
|
||||
# Download matching version of helper scripts
|
||||
echo "Updating helper scripts..."
|
||||
# Download the file into ms-man-helper.tar.gz
|
||||
if [[ $(curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$CURRENT_SCRIPT_VERSION/msman-helper.tar.gz" -o msman-helper.tar.gz) == 200 ]]; then
|
||||
# Download the file into ms-manager.tar.gz
|
||||
curl -LJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$CURRENT_SCRIPT_VERSION/ms-man-helper.tar.gz" > ms-man-helper.tar.gz
|
||||
# Check if the download was successful by checking the last line of the file for 200
|
||||
if [[ $(cat ma-man.tar.gz | tail -n 1) == 200 ]]; then
|
||||
# Remove the last line of the file
|
||||
sed -i '$d' ms-man-helper.tar.gz
|
||||
# Extract the files from ms-man-helper.tar.gz
|
||||
tar -xzf msman-helper.tar.gz
|
||||
if [ -d .msman ]; then
|
||||
# Remove the old scripts
|
||||
echo "Removing old helper scripts..."
|
||||
rm -rf .msman
|
||||
echo "Removed old script"
|
||||
fi
|
||||
tar -xzf ms-man-helper.tar.gz
|
||||
# Remove the old script
|
||||
echo "Removing old helper scripts..."
|
||||
rm -rf .ms-manager
|
||||
echo "Removed old script"
|
||||
echo "Moving new helper scripts into place..."
|
||||
mv msman/.msman .msman
|
||||
mv ms-manager .ms-manager
|
||||
echo "Removing temporary files..."
|
||||
rm msman-helper.tar.gz
|
||||
rm -rf msman
|
||||
rm ms-manager-helper.tar.gz
|
||||
echo "Helper scripts updated successfully."
|
||||
EXTRA_SCRIPTS_VERSION=$(echo $CURRENT_SCRIPT_VERSION)
|
||||
echo
|
||||
echo
|
||||
else
|
||||
echo "Failed to update helper scripts."
|
||||
rm -rf msman
|
||||
rm msman-helper.tar.gz
|
||||
rm -rf ms-manager
|
||||
rm ms-manager-helper.tar.gz
|
||||
exit 5
|
||||
fi
|
||||
}
|
||||
@ -267,33 +237,33 @@ function helper_scripts_update {
|
||||
function self_update {
|
||||
# Download the latest version of the script
|
||||
echo "Updating script..."
|
||||
# Download the file into msman_new.sh
|
||||
if [[ $(curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$LATEST_SCRIPT_VERSION/msman.sh" -o msman_new.sh) == 200 ]]; then
|
||||
# Download the file into start_new.sh
|
||||
curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$LATEST_VERSION/start.sh" > start_new.sh
|
||||
# Check if the download was successful by checking the last line of the file for 200
|
||||
if [[ $(cat start_new.sh | tail -n 1) == 200 ]]; then
|
||||
# Remove the last line of the file
|
||||
sed -i '$d' start_new.sh
|
||||
# Make the file executable
|
||||
chmod +x msman_new.sh
|
||||
chmod +x start_new.sh
|
||||
# Remove the old script
|
||||
if [[ -f msman.sh ]]; then
|
||||
echo "Removing old script..."
|
||||
rm msman.sh
|
||||
echo "Removed old script"
|
||||
fi
|
||||
echo "Moving new script into place..."
|
||||
rm start.sh
|
||||
echo "Removed old script"
|
||||
# Rename the new script
|
||||
mv msman_new.sh msman.sh
|
||||
echo "Moved new script into place"
|
||||
mv start_new.sh start.sh
|
||||
echo "Renamed new script"
|
||||
echo "Script updated successfully."
|
||||
echo
|
||||
else
|
||||
echo "Failed to update script."
|
||||
rm msman_new.sh
|
||||
rm start_new.sh
|
||||
exit 5
|
||||
fi
|
||||
}
|
||||
|
||||
# Check helper scripts update
|
||||
function check_helper_scripts {
|
||||
if [[ -d .msman ]]; then
|
||||
source "./.msman/version.sh"
|
||||
if [[ -d .ms-manager ]]; then
|
||||
source "./ms-manager/version.sh"
|
||||
if [[ $CURRENT_SCRIPT_VERSION != $EXTRA_SCRIPTS_VERSION ]]; then
|
||||
echo "Helper script verion mismatch!"
|
||||
echo "Main script version: $CURRENT_SCRIPT_VERSION"
|
||||
@ -311,7 +281,7 @@ function check_helper_scripts {
|
||||
|
||||
# Get latest script version
|
||||
function get_latest_script_release {
|
||||
response=$(curl -sL "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest")
|
||||
response=$(curl -sL "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest")
|
||||
|
||||
if [[ $response =~ "API rate limit exceeded" ]]; then
|
||||
echo "API limit exceeded. Will not check for updates."
|
||||
@ -328,10 +298,10 @@ function check_self_update {
|
||||
get_latest_script_release
|
||||
|
||||
# Compare the current version with the latest version
|
||||
if [[ "$CURRENT_SCRIPT_VERSION" != "$LATEST_SCRIPT_VERSION" ]]; then
|
||||
if [[ "$CURRENT_SCRIPT_VERSION" != "$LATEST_VERSION" ]]; then
|
||||
echo "An update is available!"
|
||||
echo "Current version: $CURRENT_SCRIPT_VERSION"
|
||||
echo "Latest version: $LATEST_SCRIPT_VERSION"
|
||||
echo "Latest version: $LATEST_VERSION"
|
||||
echo
|
||||
echo "The script will continue without updating in 15 seconds."
|
||||
echo "If you decide to update it is your responsibility to check the release notes for any breaking changes."
|
||||
@ -350,9 +320,8 @@ function check_self_update {
|
||||
read -t 15 -p "Do you want to update? [y/N] " update
|
||||
if [ "$update" == "y" ] || [ "$update" == "Y" ]; then
|
||||
self_update
|
||||
CURRENT_SCRIPT_VERSION=$LATEST_SCRIPT_VERSION
|
||||
CURRENT_VERSION=$LATEST_VERSION
|
||||
check_helper_scripts
|
||||
bash -c "$(pwd)/msman.sh"
|
||||
else
|
||||
echo "Skipping update."
|
||||
return
|
||||
@ -366,49 +335,53 @@ function check_self_update {
|
||||
# Load config
|
||||
function load_config {
|
||||
# Check if the config file exists
|
||||
if [ ! -f msman.cfg ]; then
|
||||
if [ ! -f launch.cfg ]; then
|
||||
echo "Config file does not exist."
|
||||
echo "Downloading the default config file..."
|
||||
# Download the default config file for the current version
|
||||
if [[ $(curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$CURRENT_SCRIPT_VERSION/msman.cfg" -o msman.cfg) == 200 ]]; then
|
||||
curl -sLJ -w '%{http_code}' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$CURRENT_VERSION/launch.cfg" > launch.cfg
|
||||
# Check if the download was successful by checking the last line of the file for 200
|
||||
if [[ $(cat launch.cfg | tail -n 1) == 200 ]]; then
|
||||
# Remove the last line of the file
|
||||
sed -i '$d' launch.cfg
|
||||
|
||||
echo
|
||||
read -p "Do you want to edit the config file? [y/N] " edit_config
|
||||
if [ "$edit_config" == "y" ] || [ "$edit_config" == "Y" ]; then
|
||||
if [ -z "$EDITOR" ]; then
|
||||
>&2 echo "EDITOR is not set."
|
||||
>&2 echo "Open 'msman.cfg' manually."
|
||||
>&2 echo "Open 'launch.cfg' manually."
|
||||
echo "Exiting..."
|
||||
exit 1
|
||||
else
|
||||
# Check if $EDITOR is installed
|
||||
if ! command -v $EDITOR &> /dev/null; then
|
||||
>&2 echo "$EDITOR is not installed."
|
||||
>&2 echo "Open 'msman.cfg' manually."
|
||||
>&2 echo "Open 'launch.cfg' manually."
|
||||
echo "Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
echo "Opening the config file in $EDITOR..."
|
||||
$EDITOR msman.cfg
|
||||
$EDITOR launch.cfg
|
||||
fi
|
||||
fi
|
||||
else
|
||||
>&2 echo "Failed to download the default config file."
|
||||
>&2 echo "Go to the GitHub repository for more information:"
|
||||
>&2 echo "https://github.com/$REPO_OWNER/$REPO_NAME"
|
||||
rm msman.cfg
|
||||
echo "Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load config
|
||||
source msman.cfg
|
||||
source launch.cfg
|
||||
}
|
||||
|
||||
# Delete old server file with name $old_server_file
|
||||
function delete_old_server {
|
||||
# Delete the old server file
|
||||
echo "Deleting old server file '$server_file...'"
|
||||
echo "Deleting old server file $server_file..."
|
||||
rm "$old_server_file"
|
||||
echo "Old server file deleted."
|
||||
}
|
||||
@ -417,18 +390,18 @@ function delete_old_server {
|
||||
function load_script {
|
||||
# DONE: Check if the script files exist
|
||||
# - Checked in check_helper_scripts
|
||||
source "./.msman/detect_server.sh"
|
||||
source "./.msman/java.sh"
|
||||
source "./.ms-manager/detect_server.sh"
|
||||
source "./.ms-manager/java.sh"
|
||||
|
||||
# Load the correct script
|
||||
if [[ $server_type == "paper" ]]; then
|
||||
source "./.msman/paper.sh"
|
||||
elif [[ $server_type == "fabric" ]]; then
|
||||
source "./.msman/fabric.sh"
|
||||
source "./.ms-manager/paper.sh"
|
||||
# elif [[ $server_type == "vanilla" ]]; then
|
||||
# source "$cwd/msman/vanilla.sh"
|
||||
# source "$cwd/ms-manager/vanilla.sh"
|
||||
# elif [[ $server_type == "forge" ]]; then
|
||||
# source "$cwd/msman/forge.sh"
|
||||
# source "$cwd/ms-manager/forge.sh"
|
||||
# elif [[ $server_type == "fabric" ]]; then
|
||||
# source "$cwd/ms-manager/fabric.sh"
|
||||
else
|
||||
>&2 echo "Unknown server type."
|
||||
echo "Exiting..."
|
||||
@ -440,9 +413,9 @@ function load_script {
|
||||
first_run() {
|
||||
if [[ $first_run == true ]]; then
|
||||
answer=""
|
||||
echo "Since eula wasn't accepted, this is probably the first run of the server."
|
||||
echo "Since eula wasn't accepted, this is probably the first run of the server"
|
||||
echo "If you want to install plugins (or mods), answer 'n' and you can do so."
|
||||
echo "If you don't answer, the server will start in 15 seconds."
|
||||
echo "If you don't answer, the server will start in 15 secondd."
|
||||
read -t 15 -p "Do you want to start the server now? [Y/n] " answer
|
||||
if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then
|
||||
echo "Exiting..."
|
||||
@ -476,13 +449,6 @@ function main {
|
||||
# Gets the installed server info
|
||||
get_existing_server
|
||||
|
||||
# Check if the server type differs from the one in the config
|
||||
if [[ $server_file != false ]]; then
|
||||
if [[ $existing_server_type != $server_type ]]; then
|
||||
ask_server_differs
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if the version and build are valid
|
||||
check_version_valid
|
||||
|
||||
@ -498,30 +464,23 @@ function main {
|
||||
# Check if this is the first run
|
||||
first_run
|
||||
|
||||
# Set the java arguments
|
||||
set_java_args
|
||||
# Launch the server
|
||||
launch_server
|
||||
}
|
||||
|
||||
if [[ "$1" == "--edit-config" ]] || [[ "$1" == "-e" ]]; then
|
||||
if ! command -v $EDITOR &> /dev/null; then
|
||||
echo "EDITOR is not set."
|
||||
echo "Open 'msman.cfg' manually."
|
||||
exit 1
|
||||
else
|
||||
$EDITOR msman.cfg
|
||||
exit 0
|
||||
fi
|
||||
# Check for updates on GitHub
|
||||
if [[ "$1" == "--redownload" ]] || [[ "$1" == "-r" ]]; then
|
||||
self_update
|
||||
# TODO: Add `--edit-config` option
|
||||
elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
|
||||
echo "Usage: ./msman.sh [OPTION]"
|
||||
echo "Usage: ./script.sh [OPTION]"
|
||||
echo "Starts the Minecraft server."
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -e, --edit-config Edit the config file."
|
||||
echo " -h, --help Show this help message."
|
||||
echo
|
||||
echo "To change the settings of the script, edit the 'msman.cfg' file."
|
||||
echo "Options:"
|
||||
echo " -r, --redownload Redownloads the script from GitHub."
|
||||
echo " -h, --help Show this help message."
|
||||
echo
|
||||
echo "To change the settings of the script, edit the 'launch.cfg' file."
|
||||
echo "If the file does not exist, it will be downloaded automatically when the script is run and you will be asked if you want to edit it."
|
||||
echo
|
||||
echo "For more information, see:"
|
||||
|
Loading…
x
Reference in New Issue
Block a user