Skip to content

Commit 30284d1

Browse files
committed
FIxed patchline chancing not downloading new files
1 parent e9eb3ea commit 30284d1

File tree

4 files changed

+153
-75
lines changed

4 files changed

+153
-75
lines changed

entrypoint.sh

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ source "/egg-hytale/lib/downloader.sh"
66
source "/egg-hytale/lib/plugins.sh"
77

88
DOWNLOAD_URL="https://downloader.hytale.com/hytale-downloader.zip"
9+
PATCHLINE_CACHE_FILE=".patchline-cache.txt"
910
DOWNLOAD_FILE="hytale-downloader.zip"
1011
DOWNLOADER_DIR="/egg-hytale/downloader"
1112
DOWNLOAD_CRED_FILE=".hytale-downloader-credentials.json"
@@ -28,25 +29,9 @@ chmod 755 start.sh
2829
setup_backup_directory
2930
ensure_downloader
3031

31-
# Create version file
32-
if [ ! -f "$VERSION_FILE" ]; then
33-
logger info "Creating version check file..."
34-
touch $VERSION_FILE
35-
fi
32+
create_system_files
3633

37-
#Fix system permissions
38-
if [ -f "$VERSION_FILE" ] && { [ ! -r "$VERSION_FILE" ] || [ ! -w "$VERSION_FILE" ]; }; then
39-
logger warn "Fixing permissions on $VERSION_FILE..."
40-
chmod 644 "$VERSION_FILE"
41-
fi
42-
if [ -f "$DOWNLOAD_CRED_FILE" ] && { [ ! -r "$DOWNLOAD_CRED_FILE" ] || [ ! -w "$DOWNLOAD_CRED_FILE" ]; }; then
43-
logger warn "Fixing permissions on $DOWNLOAD_CRED_FILE..."
44-
chmod 644 "$DOWNLOAD_CRED_FILE"
45-
fi
46-
if [ -f "$AUTH_CACHE_FILE" ] && { [ ! -r "$AUTH_CACHE_FILE" ] || [ ! -w "$AUTH_CACHE_FILE" ]; }; then
47-
logger warn "Fixing permissions on $AUTH_CACHE_FILE..."
48-
chmod 644 "$AUTH_CACHE_FILE"
49-
fi
34+
ensure_system_file_permissions
5035

5136
run_update_process
5237
validate_server_files

lib/downloader.sh

Lines changed: 116 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,75 +16,139 @@ ensure_downloader() {
1616
run_update_process() {
1717
local INITIAL_SETUP=0
1818

19-
# Check if credentials file exists, if not run the updater
19+
# Check if credentials file exists, if not run the initial setup
2020
if [ ! -f "$DOWNLOAD_CRED_FILE" ]; then
2121
INITIAL_SETUP=1
22-
logger warn "Credentials file not found, running initial setup..."
23-
logger info "Downloading server files..."
24-
25-
$DOWNLOADER -check-update
26-
27-
echo " "
28-
printc "{MAGENTA}╔══════════════════════════════════════════════════════════════════════════════════════╗"
29-
printc "{MAGENTA}║ {BLUE}NOTE: You must have purchased Hytale on the account you are using to authenticate. {MAGENTA}║"
30-
printc "{MAGENTA}╚══════════════════════════════════════════════════════════════════════════════════════╝"
31-
echo " "
32-
33-
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
34-
echo ""
35-
logger error "Failed to download Hytale server files."
36-
logger warn "Removing invalid credential file..."
37-
rm -f $DOWNLOAD_CRED_FILE
38-
exit 1
39-
fi
22+
run_initial_setup
23+
fi
24+
25+
# Check if automatic update is enabled
26+
if [ "$AUTOMATIC_UPDATE" = "1" ] && [ "$INITIAL_SETUP" = "0" ]; then
27+
run_auto_update
28+
fi
4029

41-
# Save version info after initial setup
42-
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
43-
if [ $? -eq 0 ] && [ -n "$DOWNLOADER_VERSION" ]; then
44-
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
45-
logger success "Saved version info!"
30+
# Check if patchline has changed if so update the server
31+
if [ -f "$PATCHLINE_CACHE_FILE" ]; then
32+
local CACHED_PATCHLINE=$(cat $PATCHLINE_CACHE_FILE)
33+
34+
if [ "$PATCHLINE" != "$CACHED_PATCHLINE" ]; then
35+
logger warn "Patchline mismatch, running update..."
36+
$DOWNLOADER -check-update
37+
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
38+
39+
save_patchline_version
40+
extract_server_files
41+
42+
logger success "Server has been successfully updated to patchline: $PATCHLINE"
43+
else
44+
logger info "Patchline match, skipping change"
4645
fi
46+
else
47+
logger warn "Patchline file not found, Saving patchline!"
48+
save_patchline_version
49+
fi
50+
}
51+
52+
run_patchline_change() {
53+
logger info "Updating server to patchline: $PATCHLINE"
54+
55+
$DOWNLOADER -check-update
56+
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
57+
echo ""
58+
logger error "Failed to download Hytale server files."
59+
logger warn "Removing invalid credential file..."
60+
rm -f $DOWNLOAD_CRED_FILE
61+
exit 1
62+
fi
63+
64+
echo "$PATCHLINE" > "$PATCHLINE_CACHE_FILE"
65+
logger success "Selected patchline saved!"
66+
67+
save_downloader_version
68+
69+
extract_server_files
70+
logger success "Server has been successfully updated to patchline: $PATCHLINE"
71+
}
4772

48-
extract_server_files
73+
run_initial_setup() {
74+
logger warn "Credentials file not found, running initial setup..."
75+
logger info "Downloading server files..."
76+
77+
$DOWNLOADER -check-update
78+
79+
echo " "
80+
printc "{MAGENTA}╔══════════════════════════════════════════════════════════════════════════════════════╗"
81+
printc "{MAGENTA}║ {BLUE}NOTE: You must have purchased Hytale on the account you are using to authenticate. {MAGENTA}║"
82+
printc "{MAGENTA}╚══════════════════════════════════════════════════════════════════════════════════════╝"
83+
echo " "
84+
85+
if ! $DOWNLOADER -patchline $PATCHLINE -download-path server.zip; then
86+
echo ""
87+
logger error "Failed to download Hytale server files."
88+
logger warn "Removing invalid credential file..."
89+
rm -f $DOWNLOAD_CRED_FILE
90+
exit 1
4991
fi
5092

93+
save_patchline_version
94+
save_downloader_version
95+
extract_server_files
96+
}
97+
98+
run_auto_update() {
5199
# Run automatic update if enabled
52-
if [ "$AUTOMATIC_UPDATE" = "1" ] && [ "$INITIAL_SETUP" = "0" ]; then
53-
logger info "Checking for updates..."
100+
logger info "Checking for updates..."
54101

55-
local LOCAL_VERSION=""
56-
if [ -f "$VERSION_FILE" ]; then
57-
LOCAL_VERSION=$(cat $VERSION_FILE)
58-
else
59-
logger warn "Version file not found, forcing update"
102+
local LOCAL_VERSION=""
103+
if [ -f "$VERSION_FILE" ]; then
104+
LOCAL_VERSION=$(cat $VERSION_FILE)
105+
else
106+
logger warn "Version file not found, forcing update"
107+
fi
108+
109+
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
110+
111+
if [ $? -ne 0 ] || [ -z "$DOWNLOADER_VERSION" ]; then
112+
logger error "Failed to get downloader version."
113+
exit 1
114+
else
115+
if [ -n "$LOCAL_VERSION" ]; then
116+
logger info "Local version: $LOCAL_VERSION"
60117
fi
118+
logger info "Downloader version: $DOWNLOADER_VERSION"
119+
120+
if [ "$LOCAL_VERSION" != "$DOWNLOADER_VERSION" ]; then
121+
logger warn "Version mismatch, running update..."
122+
$DOWNLOADER -check-update
123+
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
61124

62-
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
125+
save_patchline_version
126+
save_downloader_version
63127

64-
if [ $? -ne 0 ] || [ -z "$DOWNLOADER_VERSION" ]; then
65-
logger error "Failed to get downloader version."
66-
exit 1
128+
extract_server_files
129+
logger success "Server has been updated successfully!"
67130
else
68-
if [ -n "$LOCAL_VERSION" ]; then
69-
logger info "Local version: $LOCAL_VERSION"
70-
fi
71-
logger info "Downloader version: $DOWNLOADER_VERSION"
72-
73-
if [ "$LOCAL_VERSION" != "$DOWNLOADER_VERSION" ]; then
74-
logger warn "Version mismatch, running update..."
75-
$DOWNLOADER -check-update
76-
$DOWNLOADER -patchline $PATCHLINE -download-path server.zip
77-
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
78-
logger success "Saved version info!"
79-
extract_server_files
80-
logger success "Server has been updated successfully!"
81-
else
82-
logger info "Versions match, skipping update"
83-
fi
131+
logger info "Versions match, skipping update"
84132
fi
85133
fi
86134
}
87135

136+
save_patchline_version() {
137+
echo "$PATCHLINE" > $PATCHLINE_CACHE_FILE
138+
logger success "Selected patchline saved!"
139+
}
140+
141+
save_downloader_version() {
142+
local DOWNLOADER_VERSION=$($DOWNLOADER -print-version -skip-update-check 2>&1)
143+
if [ $? -eq 0 ] && [ -n "$DOWNLOADER_VERSION" ]; then
144+
echo "$DOWNLOADER_VERSION" > $VERSION_FILE
145+
logger success "Saved version info!"
146+
else
147+
logger error "Failed to get downloader version."
148+
exit 1
149+
fi
150+
}
151+
88152
validate_server_files() {
89153
if [ ! -f "HytaleServer.jar" ]; then
90154
logger error "HytaleServer.jar not found!"

lib/system.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
#!/bin/bash
22

3+
create_system_files() {
4+
# Create version file
5+
if [ ! -f "$VERSION_FILE" ]; then
6+
logger info "Creating version check file..."
7+
touch $VERSION_FILE
8+
fi
9+
10+
if [ ! -f "$PATCHLINE_CACHE_FILE" ]; then
11+
logger info "Creating patchline cache file..."
12+
touch $PATCHLINE_CACHE_FILE
13+
fi
14+
}
15+
16+
ensure_system_file_permissions() {
17+
#Fix system permissions
18+
if [ -f "$VERSION_FILE" ] && { [ ! -r "$VERSION_FILE" ] || [ ! -w "$VERSION_FILE" ]; }; then
19+
logger warn "Fixing permissions on $VERSION_FILE..."
20+
chmod 644 "$VERSION_FILE"
21+
fi
22+
if [ -f "$PATCHLINE_CACHE_FILE" ] && { [ ! -r "$PATCHLINE_CACHE_FILE" ] || [ ! -w "$PATCHLINE_CACHE_FILE" ]; }; then
23+
logger warn "Fixing permissions on $PATCHLINE_CACHE_FILE..."
24+
chmod 644 "$PATCHLINE_CACHE_FILE"
25+
fi
26+
if [ -f "$DOWNLOAD_CRED_FILE" ] && { [ ! -r "$DOWNLOAD_CRED_FILE" ] || [ ! -w "$DOWNLOAD_CRED_FILE" ]; }; then
27+
logger warn "Fixing permissions on $DOWNLOAD_CRED_FILE..."
28+
chmod 644 "$DOWNLOAD_CRED_FILE"
29+
fi
30+
if [ -f "$AUTH_CACHE_FILE" ] && { [ ! -r "$AUTH_CACHE_FILE" ] || [ ! -w "$AUTH_CACHE_FILE" ]; }; then
31+
logger warn "Fixing permissions on $AUTH_CACHE_FILE..."
32+
chmod 644 "$AUTH_CACHE_FILE"
33+
fi
34+
}
35+
336
detect_architecture() {
437
local ARCH=$(uname -m)
538
logger info "Platform: $ARCH"

start.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,12 @@ if [ "${ENABLE_BACKUPS}" = "1" ]; then
9191
JAVA_CMD="${JAVA_CMD} --backup --backup-dir ./backup --backup-frequency ${BACKUP_FREQUENCY} --backup-max-count ${MAXIMUM_BACKUPS}"
9292
fi
9393

94-
# Add session tokens and owner UUID
94+
# Add session tokens
9595
if [ -n "${SESSION_TOKEN}" ]; then
9696
JAVA_CMD="${JAVA_CMD} --session-token ${SESSION_TOKEN}"
97-
else
98-
echo "Warning: SESSION_TOKEN is not set"
9997
fi
10098
if [ -n "${IDENTITY_TOKEN}" ]; then
10199
JAVA_CMD="${JAVA_CMD} --identity-token ${IDENTITY_TOKEN}"
102-
else
103-
echo "Warning: IDENTITY_TOKEN is not set"
104100
fi
105101

106102
# Add bind address

0 commit comments

Comments
 (0)