mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-07-05 16:15:10 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9ee3ee68c | |||
| ab505fa43c |
@@ -35,7 +35,7 @@ For optimal performance choose java25 with GTNH 2.8.0 and later.
|
|||||||
|
|
||||||
## Config backups
|
## Config backups
|
||||||
|
|
||||||
During version upgrade, the server will replace all config files to make sure all new features are setup as intended. The old config files are stored in a backup folder in the data directory, for you to use as reference for manual reapplication of your changed settings. Set the environment variable `GTNH_DELETE_BACKUPS` to true to delete all backup folders at startup.
|
During version upgrade, the server will replace all config files to make sure all new features are setup as intended. The old config files are stored in a backup folder in the data directory, for you to use as reference for manual reapplication of your changed settings. The folder name starts with `gtnh-upgrade-` followed by a timestamp. Set the environment variable `GTNH_DELETE_BACKUPS` to true to delete all backup folders at startup.
|
||||||
|
|
||||||
## server.properties defaults
|
## server.properties defaults
|
||||||
|
|
||||||
|
|||||||
+115
-88
@@ -7,7 +7,8 @@
|
|||||||
function getGTNHdownloadPath(){
|
function getGTNHdownloadPath(){
|
||||||
gtnh_download_path=""
|
gtnh_download_path=""
|
||||||
local release_object=""
|
local release_object=""
|
||||||
local current_java_version=$(mc-image-helper java-release)
|
local current_java_version=""
|
||||||
|
current_java_version=$(mc-image-helper java-release)
|
||||||
|
|
||||||
# Select release JSON object
|
# Select release JSON object
|
||||||
if [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
if [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
||||||
@@ -39,6 +40,11 @@ function getGTNHdownloadPath(){
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $release_object ]]; then
|
||||||
|
logError "No release found for GTNH_PACK_VERSION=$GTNH_PACK_VERSION. Please check if the version is valid."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Select compatible server files for java version
|
# Select compatible server files for java version
|
||||||
if (( current_java_version == 8 )); then
|
if (( current_java_version == 8 )); then
|
||||||
gtnh_download_path=$(jq -r '.value.server.java8Url' <<< "$release_object")
|
gtnh_download_path=$(jq -r '.value.server.java8Url' <<< "$release_object")
|
||||||
@@ -59,6 +65,10 @@ function getGTNHdownloadPath(){
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $gtnh_download_path ]]; then
|
||||||
|
logError "Server files not found! Please check if the selected GTNH_PACK_VERSION=$GTNH_PACK_VERSION is valid."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
debug "Download source URL: $gtnh_download_path"
|
debug "Download source URL: $gtnh_download_path"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -70,80 +80,125 @@ function deleteGTNHbackup(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadGTNH(){
|
||||||
|
local gtnh_download=""
|
||||||
|
base_dir=/data/.tmp/gtnh_base
|
||||||
|
|
||||||
|
debug "Creating temporary /data/.tmp/packs folder for GTNH download"
|
||||||
|
mkdir -p /data/.tmp/packs
|
||||||
|
trap 'rm -rf /data/.tmp' EXIT
|
||||||
|
|
||||||
|
log "Downloading $gtnh_download_path."
|
||||||
|
if ! gtnh_download=$(mc-image-helper get -o /data/.tmp/packs --output-filename --skip-up-to-date "$gtnh_download_path"); then
|
||||||
|
logError "Failed to download $gtnh_download_path"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
debug "Downloaded GTNH server files to $gtnh_download"
|
||||||
|
|
||||||
|
# Unpacking Server files into temporary directory
|
||||||
|
log "Unpacking Server Files into $base_dir"
|
||||||
|
mkdir -p "${base_dir}"
|
||||||
|
extract "${gtnh_download}" "${base_dir}"
|
||||||
|
|
||||||
|
# Remove any eula file since container manages it
|
||||||
|
debug "Removing eula.txt from $base_dir"
|
||||||
|
rm -f "${base_dir}/eula.txt"
|
||||||
|
|
||||||
|
# recalculate the actual base directory of content
|
||||||
|
if ! base_dir=$(mc-image-helper find \
|
||||||
|
--max-depth=3 --type=directory --name=mods,config \
|
||||||
|
--only-shallowest --fail-no-matches --format '%h' \
|
||||||
|
"$base_dir"); then
|
||||||
|
logError "Unable to find content base of downloaded Server Files"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
debug "Base directory of unpacked Server Files: $base_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGTNHresource(){
|
||||||
|
local resource="$1"
|
||||||
|
local new_resource="$2"
|
||||||
|
log "Trying to update $resource"
|
||||||
|
|
||||||
|
if [[ -z "$resource" ]]; then
|
||||||
|
logWarning "No resource specified for update"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -e "$resource" ]]; then
|
||||||
|
log "Deleting existing resource: $resource"
|
||||||
|
if ! rm -rf "$resource"; then
|
||||||
|
logError "Failed to delete resource: $resource"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$new_resource" ]]; then
|
||||||
|
log "Copying $new_resource to /data"
|
||||||
|
if ! cp -r "$new_resource" "/data/"; then
|
||||||
|
logError "Failed to copy $new_resource to /data"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [[ -f "$new_resource" ]]; then
|
||||||
|
log "Copying $new_resource to /data"
|
||||||
|
if ! cp "$new_resource" "/data/"; then
|
||||||
|
logError "Failed to copy $new_resource to /data"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
logWarning "Resource update failed: $new_resource does not exist!"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
function updateGTNH(){
|
function updateGTNH(){
|
||||||
# Get the current date and time
|
# Get the current date and time
|
||||||
current_datetime=$(date +%Y-%m-%dT%H:%M)
|
local current_datetime=""
|
||||||
|
current_datetime=$(date +%Y-%m-%dT+%H%M)
|
||||||
|
|
||||||
# Define folders and files to update
|
# Define folders and files to update
|
||||||
folders_to_update=("libraries" "mods" "resources" "scripts")
|
# base_dir is already defined in handleGTNH function
|
||||||
files_to_update=("lwjgl3ify-forgePatches.jar" "java9args.txt" "startserver-java9.bat" "startserver-java9.sh" "forge-1.7.10-10.13.4.1614-1.7.10-universal.jar" "startserver.bat" "startserver.sh" "server-icon.png")
|
local folders_to_update=("libraries" "mods" "resources" "scripts")
|
||||||
config_folder="config"
|
local files_to_update=("lwjgl3ify-forgePatches.jar" "java9args.txt" "startserver-java9.bat" "startserver-java9.sh" "forge-1.7.10-10.13.4.1614-1.7.10-universal.jar" "startserver.bat" "startserver.sh" "server-icon.png")
|
||||||
backup_folder="/data/gtnh-upgrade-$current_datetime"
|
local config_folder="config"
|
||||||
journey_map_folder="JourneyMapServer"
|
local backup_folder="/data/gtnh-upgrade-$current_datetime"
|
||||||
|
local journey_map_folder="JourneyMapServer"
|
||||||
# Delete specified folders if they exist
|
|
||||||
for folder in "${folders_to_update[@]}"; do
|
|
||||||
folder_path="/data/$folder"
|
|
||||||
if [[ -d "$folder_path" ]]; then
|
|
||||||
log "Deleting folder: $folder_path"
|
|
||||||
rm -rf "$folder_path"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Delete specific files if they exist
|
|
||||||
for file in "${files_to_update[@]}"; do
|
|
||||||
file_path="/data/$file"
|
|
||||||
if [[ -f "$file_path" ]]; then
|
|
||||||
log "Deleting file: $file_path"
|
|
||||||
rm -f "$file_path"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Backup the config folder
|
# Backup the config folder
|
||||||
if [[ -d "/data/$config_folder" ]]; then
|
if [[ -d "/data/$config_folder" ]]; then
|
||||||
log "Creating backup of /data/$config_folder at $backup_folder"
|
log "Creating backup of /data/$config_folder at $backup_folder"
|
||||||
cp -r "/data/$config_folder" "$backup_folder"
|
cp -r "/data/$config_folder" "$backup_folder"
|
||||||
log "Deleting original /data/$config_folder"
|
|
||||||
rm -rf "/data/$config_folder"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Updating the required folders in data directory
|
# Update resources from unpacked server files to /data
|
||||||
for folder in "${folders_to_update[@]}" "$config_folder"; do
|
for resource in "${folders_to_update[@]}" "$config_folder" "${files_to_update[@]}"; do
|
||||||
if [[ -d "$base_dir/$folder" ]]; then
|
local resource_path="/data/$resource"
|
||||||
log "Copying $folder to /data"
|
local new_resource_path="$base_dir/$resource"
|
||||||
cp -r "$base_dir/$folder" "/data/"
|
|
||||||
else
|
|
||||||
logWarning "Folder $folder not found in the unzipped data!"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Copy specific files to the /data directory
|
debug "Updating resource: $resource_path with new resource: $new_resource_path"
|
||||||
for file in "${files_to_update[@]}"; do
|
updateGTNHresource "$resource_path" "$new_resource_path"
|
||||||
if [[ -f "$base_dir/$file" ]]; then
|
|
||||||
log "Copying $file to /data"
|
|
||||||
cp "$base_dir/$file" "/data/"
|
|
||||||
else
|
|
||||||
logWarning "File $file not found in the unzipped data!"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Ensure the config folder exists
|
|
||||||
if [[ ! -d "$config_folder" ]]; then
|
|
||||||
log "$config_folder does not exist. Creating it now."
|
|
||||||
mkdir -p "$config_folder"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restore JourneyMapServer folder from backup
|
# Restore JourneyMapServer folder from backup
|
||||||
if [[ -d "$backup_folder/$journey_map_folder" ]]; then
|
if [[ -d "$backup_folder/$journey_map_folder" ]]; then
|
||||||
log "Restoring $journey_map_folder to $config_folder"
|
if [[ ! -d "/data/$config_folder" ]]; then
|
||||||
cp -r "$backup_folder/$journey_map_folder" "$config_folder/"
|
log "/data/$config_folder folder does not exist. Creating it now."
|
||||||
|
mkdir -p "/data/$config_folder"
|
||||||
|
fi
|
||||||
|
log "Restoring $journey_map_folder to /data/$config_folder"
|
||||||
|
cp -r "$backup_folder/$journey_map_folder" "/data/$config_folder/"
|
||||||
else
|
else
|
||||||
logWarning "$journey_map_folder not found in backup!"
|
logWarning "$journey_map_folder not found in backup!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the changelog file to /data
|
# Copy the changelog file to /data
|
||||||
|
local gtnh_changelog_file=""
|
||||||
gtnh_changelog_file=$(mc-image-helper find --max-depth=1 --type=file --name=changelog*.md "$base_dir")
|
gtnh_changelog_file=$(mc-image-helper find --max-depth=1 --type=file --name=changelog*.md "$base_dir")
|
||||||
if [[ -n "$gtnh_changelog_file" ]]; then
|
if [[ -n "$gtnh_changelog_file" ]]; then
|
||||||
|
debug "Found changelog file: $gtnh_changelog_file"
|
||||||
log "Copying changelog file to /data"
|
log "Copying changelog file to /data"
|
||||||
cp -f "$gtnh_changelog_file" /data/
|
cp -f "$gtnh_changelog_file" /data/
|
||||||
fi
|
fi
|
||||||
@@ -163,46 +218,16 @@ function handleGTNH() {
|
|||||||
if [[ -n "$GTNH_PACK_VERSION" ]] && isFalse "$SKIP_GTNH_UPDATE_CHECK" ; then
|
if [[ -n "$GTNH_PACK_VERSION" ]] && isFalse "$SKIP_GTNH_UPDATE_CHECK" ; then
|
||||||
|
|
||||||
getGTNHdownloadPath
|
getGTNHdownloadPath
|
||||||
|
|
||||||
if [[ -z $gtnh_download_path ]]; then
|
|
||||||
logError "Server files not found for GTNH_PACK_VERSION=$GTNH_PACK_VERSION! Download not possible!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
log "Server files located! Will proceed update $gtnh_download_path."
|
log "Server files located! Will proceed update $gtnh_download_path."
|
||||||
|
|
||||||
|
|
||||||
# Decide if update or install is needed or not.
|
# Decide if update or install is needed or not.
|
||||||
if [[ ! -f /data/.gtnh-version || "$(basename "$gtnh_download_path")" != "$(cat /data/.gtnh-version)" ]]; then
|
if [[ ! -f /data/.gtnh-version || "$(basename "$gtnh_download_path")" != "$(cat /data/.gtnh-version)" ]]; then
|
||||||
log "Update/Install required: /data/.gtnh-version is missing or does not match the selected version $(basename "$gtnh_download_path")."
|
log "Update/Install required: /data/.gtnh-version is missing or does not match the selected version $(basename "$gtnh_download_path")."
|
||||||
|
|
||||||
mkdir -p /data/packs
|
# Download and unpack GTNH server files
|
||||||
log "Downloading $gtnh_download_path."
|
downloadGTNH
|
||||||
if ! gtnh_download=$(mc-image-helper get -o /data/packs --output-filename --skip-up-to-date "$gtnh_download_path"); then
|
log "GTNH server files downloaded and unpacked to $base_dir."
|
||||||
logError "Failed to download $gtnh_download_path"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Unpacking Server files into temporary directory
|
|
||||||
log "Unpacking Server Files..."
|
|
||||||
original_base_dir=/data/.tmp/gtnh_base
|
|
||||||
base_dir=$original_base_dir
|
|
||||||
rm -rf "${base_dir}"
|
|
||||||
mkdir -p "${base_dir}"
|
|
||||||
extract "${gtnh_download}" "${base_dir}"
|
|
||||||
trap 'rm -rf /data/.tmp' EXIT
|
|
||||||
# Removing downloaded zip
|
|
||||||
rm -f "$gtnh_download"
|
|
||||||
|
|
||||||
# Remove any eula file since container manages it
|
|
||||||
rm -f "${base_dir}/eula.txt"
|
|
||||||
|
|
||||||
# recalculate the actual base directory of content
|
|
||||||
if ! base_dir=$(mc-image-helper find \
|
|
||||||
--max-depth=3 --type=directory --name=mods,config \
|
|
||||||
--only-shallowest --fail-no-matches --format '%h' \
|
|
||||||
"$base_dir"); then
|
|
||||||
logError "Unable to find content base of downloaded Server Files"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Split installation from update path. Check for version file.
|
# Split installation from update path. Check for version file.
|
||||||
if [[ -f /data/.gtnh-version ]]; then
|
if [[ -f /data/.gtnh-version ]]; then
|
||||||
@@ -212,10 +237,12 @@ function handleGTNH() {
|
|||||||
log "No .gtnh-version file detected! Assuming no old server exists. Proceed installing new server..."
|
log "No .gtnh-version file detected! Assuming no old server exists. Proceed installing new server..."
|
||||||
cp -R -f "${base_dir}"/* /data
|
cp -R -f "${base_dir}"/* /data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update .gtnh-version
|
# Update .gtnh-version
|
||||||
basename "$gtnh_download_path" > /data/.gtnh-version
|
basename "$gtnh_download_path" > /data/.gtnh-version
|
||||||
# Cleaning up
|
|
||||||
rm -rf "$original_base_dir"
|
# Cleaning up temporary files
|
||||||
|
rm -rf /data/.tmp
|
||||||
|
|
||||||
else
|
else
|
||||||
log "No update required: /data/.gtnh-version matches the selected version $(basename "$gtnh_download_path")."
|
log "No update required: /data/.gtnh-version matches the selected version $(basename "$gtnh_download_path")."
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ setupOnlyMinecraftTest(){
|
|||||||
start=$(date +%s)
|
start=$(date +%s)
|
||||||
status=PASSED
|
status=PASSED
|
||||||
verify=
|
verify=
|
||||||
if ! logs=$(docker compose run --rm -e SETUP_ONLY=true -e DEBUG="${DEBUG:-false}" mc 2>&1); then
|
if ! logs=$(docker compose run --rm -e SETUP_ONLY=true -e DEBUG="${DEBUG:-false}" -e GH_TOKEN="${GH_TOKEN:-}" mc 2>&1); then
|
||||||
status=FAILED
|
status=FAILED
|
||||||
outputContainerLog "$logs"
|
outputContainerLog "$logs"
|
||||||
result=1
|
result=1
|
||||||
|
|||||||
Reference in New Issue
Block a user