mirror of
https://github.com/NATroutter/egg-hytale.git
synced 2026-03-01 11:21:13 +03:00
FIxed patchline chancing not downloading new files
This commit is contained in:
@@ -6,6 +6,7 @@ source "/egg-hytale/lib/downloader.sh"
|
||||
source "/egg-hytale/lib/plugins.sh"
|
||||
|
||||
DOWNLOAD_URL="https://downloader.hytale.com/hytale-downloader.zip"
|
||||
PATCHLINE_CACHE_FILE=".patchline-cache.txt"
|
||||
DOWNLOAD_FILE="hytale-downloader.zip"
|
||||
DOWNLOADER_DIR="/egg-hytale/downloader"
|
||||
DOWNLOAD_CRED_FILE=".hytale-downloader-credentials.json"
|
||||
@@ -28,25 +29,9 @@ chmod 755 start.sh
|
||||
setup_backup_directory
|
||||
ensure_downloader
|
||||
|
||||
# Create version file
|
||||
if [ ! -f "$VERSION_FILE" ]; then
|
||||
logger info "Creating version check file..."
|
||||
touch $VERSION_FILE
|
||||
fi
|
||||
create_system_files
|
||||
|
||||
#Fix system permissions
|
||||
if [ -f "$VERSION_FILE" ] && { [ ! -r "$VERSION_FILE" ] || [ ! -w "$VERSION_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $VERSION_FILE..."
|
||||
chmod 644 "$VERSION_FILE"
|
||||
fi
|
||||
if [ -f "$DOWNLOAD_CRED_FILE" ] && { [ ! -r "$DOWNLOAD_CRED_FILE" ] || [ ! -w "$DOWNLOAD_CRED_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $DOWNLOAD_CRED_FILE..."
|
||||
chmod 644 "$DOWNLOAD_CRED_FILE"
|
||||
fi
|
||||
if [ -f "$AUTH_CACHE_FILE" ] && { [ ! -r "$AUTH_CACHE_FILE" ] || [ ! -w "$AUTH_CACHE_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $AUTH_CACHE_FILE..."
|
||||
chmod 644 "$AUTH_CACHE_FILE"
|
||||
fi
|
||||
ensure_system_file_permissions
|
||||
|
||||
run_update_process
|
||||
validate_server_files
|
||||
|
||||
@@ -16,75 +16,139 @@ ensure_downloader() {
|
||||
run_update_process() {
|
||||
local INITIAL_SETUP=0
|
||||
|
||||
# Check if credentials file exists, if not run the updater
|
||||
# Check if credentials file exists, if not run the initial setup
|
||||
if [ ! -f "$DOWNLOAD_CRED_FILE" ]; then
|
||||
INITIAL_SETUP=1
|
||||
logger warn "Credentials file not found, running initial setup..."
|
||||
logger info "Downloading server files..."
|
||||
|
||||
$DOWNLOADER -check-update
|
||||
|
||||
echo " "
|
||||
printc "{MAGENTA}╔══════════════════════════════════════════════════════════════════════════════════════╗"
|
||||
printc "{MAGENTA}║ {BLUE}NOTE: You must have purchased Hytale on the account you are using to authenticate. {MAGENTA}║"
|
||||
printc "{MAGENTA}╚══════════════════════════════════════════════════════════════════════════════════════╝"
|
||||
echo " "
|
||||
|
||||
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
|
||||
echo ""
|
||||
logger error "Failed to download Hytale server files."
|
||||
logger warn "Removing invalid credential file..."
|
||||
rm -f $DOWNLOAD_CRED_FILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save version info after initial setup
|
||||
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
|
||||
if [ $? -eq 0 ] && [ -n "$DOWNLOADER_VERSION" ]; then
|
||||
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
|
||||
logger success "Saved version info!"
|
||||
fi
|
||||
|
||||
extract_server_files
|
||||
run_initial_setup
|
||||
fi
|
||||
|
||||
# Run automatic update if enabled
|
||||
# Check if automatic update is enabled
|
||||
if [ "$AUTOMATIC_UPDATE" = "1" ] && [ "$INITIAL_SETUP" = "0" ]; then
|
||||
logger info "Checking for updates..."
|
||||
run_auto_update
|
||||
fi
|
||||
|
||||
local LOCAL_VERSION=""
|
||||
if [ -f "$VERSION_FILE" ]; then
|
||||
LOCAL_VERSION=$(cat $VERSION_FILE)
|
||||
# Check if patchline has changed if so update the server
|
||||
if [ -f "$PATCHLINE_CACHE_FILE" ]; then
|
||||
local CACHED_PATCHLINE=$(cat $PATCHLINE_CACHE_FILE)
|
||||
|
||||
if [ "$PATCHLINE" != "$CACHED_PATCHLINE" ]; then
|
||||
logger warn "Patchline mismatch, running update..."
|
||||
$DOWNLOADER -check-update
|
||||
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
|
||||
|
||||
save_patchline_version
|
||||
extract_server_files
|
||||
|
||||
logger success "Server has been successfully updated to patchline: $PATCHLINE"
|
||||
else
|
||||
logger warn "Version file not found, forcing update"
|
||||
logger info "Patchline match, skipping change"
|
||||
fi
|
||||
else
|
||||
logger warn "Patchline file not found, Saving patchline!"
|
||||
save_patchline_version
|
||||
fi
|
||||
}
|
||||
|
||||
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
|
||||
run_patchline_change() {
|
||||
logger info "Updating server to patchline: $PATCHLINE"
|
||||
|
||||
if [ $? -ne 0 ] || [ -z "$DOWNLOADER_VERSION" ]; then
|
||||
logger error "Failed to get downloader version."
|
||||
exit 1
|
||||
$DOWNLOADER -check-update
|
||||
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
|
||||
echo ""
|
||||
logger error "Failed to download Hytale server files."
|
||||
logger warn "Removing invalid credential file..."
|
||||
rm -f $DOWNLOAD_CRED_FILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$PATCHLINE" > "$PATCHLINE_CACHE_FILE"
|
||||
logger success "Selected patchline saved!"
|
||||
|
||||
save_downloader_version
|
||||
|
||||
extract_server_files
|
||||
logger success "Server has been successfully updated to patchline: $PATCHLINE"
|
||||
}
|
||||
|
||||
run_initial_setup() {
|
||||
logger warn "Credentials file not found, running initial setup..."
|
||||
logger info "Downloading server files..."
|
||||
|
||||
$DOWNLOADER -check-update
|
||||
|
||||
echo " "
|
||||
printc "{MAGENTA}╔══════════════════════════════════════════════════════════════════════════════════════╗"
|
||||
printc "{MAGENTA}║ {BLUE}NOTE: You must have purchased Hytale on the account you are using to authenticate. {MAGENTA}║"
|
||||
printc "{MAGENTA}╚══════════════════════════════════════════════════════════════════════════════════════╝"
|
||||
echo " "
|
||||
|
||||
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
|
||||
echo ""
|
||||
logger error "Failed to download Hytale server files."
|
||||
logger warn "Removing invalid credential file..."
|
||||
rm -f $DOWNLOAD_CRED_FILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
save_patchline_version
|
||||
save_downloader_version
|
||||
extract_server_files
|
||||
}
|
||||
|
||||
run_auto_update() {
|
||||
# Run automatic update if enabled
|
||||
logger info "Checking for updates..."
|
||||
|
||||
local LOCAL_VERSION=""
|
||||
if [ -f "$VERSION_FILE" ]; then
|
||||
LOCAL_VERSION=$(cat $VERSION_FILE)
|
||||
else
|
||||
logger warn "Version file not found, forcing update"
|
||||
fi
|
||||
|
||||
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
|
||||
|
||||
if [ $? -ne 0 ] || [ -z "$DOWNLOADER_VERSION" ]; then
|
||||
logger error "Failed to get downloader version."
|
||||
exit 1
|
||||
else
|
||||
if [ -n "$LOCAL_VERSION" ]; then
|
||||
logger info "Local version: $LOCAL_VERSION"
|
||||
fi
|
||||
logger info "Downloader version: $DOWNLOADER_VERSION"
|
||||
|
||||
if [ "$LOCAL_VERSION" != "$DOWNLOADER_VERSION" ]; then
|
||||
logger warn "Version mismatch, running update..."
|
||||
$DOWNLOADER -check-update
|
||||
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
|
||||
|
||||
save_patchline_version
|
||||
save_downloader_version
|
||||
|
||||
extract_server_files
|
||||
logger success "Server has been updated successfully!"
|
||||
else
|
||||
if [ -n "$LOCAL_VERSION" ]; then
|
||||
logger info "Local version: $LOCAL_VERSION"
|
||||
fi
|
||||
logger info "Downloader version: $DOWNLOADER_VERSION"
|
||||
|
||||
if [ "$LOCAL_VERSION" != "$DOWNLOADER_VERSION" ]; then
|
||||
logger warn "Version mismatch, running update..."
|
||||
$DOWNLOADER -check-update
|
||||
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
|
||||
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
|
||||
logger success "Saved version info!"
|
||||
extract_server_files
|
||||
logger success "Server has been updated successfully!"
|
||||
else
|
||||
logger info "Versions match, skipping update"
|
||||
fi
|
||||
logger info "Versions match, skipping update"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
save_patchline_version() {
|
||||
echo "$PATCHLINE" > $PATCHLINE_CACHE_FILE
|
||||
logger success "Selected patchline saved!"
|
||||
}
|
||||
|
||||
save_downloader_version() {
|
||||
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
|
||||
if [ $? -eq 0 ] && [ -n "$DOWNLOADER_VERSION" ]; then
|
||||
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
|
||||
logger success "Saved version info!"
|
||||
else
|
||||
logger error "Failed to get downloader version."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_server_files() {
|
||||
if [ ! -f "HytaleServer.jar" ]; then
|
||||
logger error "HytaleServer.jar not found!"
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
create_system_files() {
|
||||
# Create version file
|
||||
if [ ! -f "$VERSION_FILE" ]; then
|
||||
logger info "Creating version check file..."
|
||||
touch $VERSION_FILE
|
||||
fi
|
||||
|
||||
if [ ! -f "$PATCHLINE_CACHE_FILE" ]; then
|
||||
logger info "Creating patchline cache file..."
|
||||
touch $PATCHLINE_CACHE_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_system_file_permissions() {
|
||||
#Fix system permissions
|
||||
if [ -f "$VERSION_FILE" ] && { [ ! -r "$VERSION_FILE" ] || [ ! -w "$VERSION_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $VERSION_FILE..."
|
||||
chmod 644 "$VERSION_FILE"
|
||||
fi
|
||||
if [ -f "$PATCHLINE_CACHE_FILE" ] && { [ ! -r "$PATCHLINE_CACHE_FILE" ] || [ ! -w "$PATCHLINE_CACHE_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $PATCHLINE_CACHE_FILE..."
|
||||
chmod 644 "$PATCHLINE_CACHE_FILE"
|
||||
fi
|
||||
if [ -f "$DOWNLOAD_CRED_FILE" ] && { [ ! -r "$DOWNLOAD_CRED_FILE" ] || [ ! -w "$DOWNLOAD_CRED_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $DOWNLOAD_CRED_FILE..."
|
||||
chmod 644 "$DOWNLOAD_CRED_FILE"
|
||||
fi
|
||||
if [ -f "$AUTH_CACHE_FILE" ] && { [ ! -r "$AUTH_CACHE_FILE" ] || [ ! -w "$AUTH_CACHE_FILE" ]; }; then
|
||||
logger warn "Fixing permissions on $AUTH_CACHE_FILE..."
|
||||
chmod 644 "$AUTH_CACHE_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
detect_architecture() {
|
||||
local ARCH=$(uname -m)
|
||||
logger info "Platform: $ARCH"
|
||||
|
||||
6
start.sh
6
start.sh
@@ -91,16 +91,12 @@ if [ "${ENABLE_BACKUPS}" = "1" ]; then
|
||||
JAVA_CMD="${JAVA_CMD} --backup --backup-dir ./backup --backup-frequency ${BACKUP_FREQUENCY} --backup-max-count ${MAXIMUM_BACKUPS}"
|
||||
fi
|
||||
|
||||
# Add session tokens and owner UUID
|
||||
# Add session tokens
|
||||
if [ -n "${SESSION_TOKEN}" ]; then
|
||||
JAVA_CMD="${JAVA_CMD} --session-token ${SESSION_TOKEN}"
|
||||
else
|
||||
echo "Warning: SESSION_TOKEN is not set"
|
||||
fi
|
||||
if [ -n "${IDENTITY_TOKEN}" ]; then
|
||||
JAVA_CMD="${JAVA_CMD} --identity-token ${IDENTITY_TOKEN}"
|
||||
else
|
||||
echo "Warning: IDENTITY_TOKEN is not set"
|
||||
fi
|
||||
|
||||
# Add bind address
|
||||
|
||||
Reference in New Issue
Block a user