mirror of
https://github.com/edu4rdshl/hytale-server-setup.git
synced 2026-07-17 23:24:52 +00:00
Enhance update process with version normalization and improved restart instructions
This commit is contained in:
parent
93bcb7d2d8
commit
5d659db44e
1 changed files with 37 additions and 11 deletions
|
|
@ -221,16 +221,20 @@ do_update() {
|
||||||
|
|
||||||
log_info "Latest version: ${CYAN}$LATEST_VERSION${NC}"
|
log_info "Latest version: ${CYAN}$LATEST_VERSION${NC}"
|
||||||
|
|
||||||
|
# Normalize current version for comparison
|
||||||
|
# Extract just the date-hash part (e.g., "2026.01.13-50e69c385" from "HytaleServer v2026.01.13-50e69c385 (release)")
|
||||||
|
CURRENT_VERSION_NORMALIZED=$(echo "$CURRENT_VERSION" | grep -oP '[0-9]{4}\.[0-9]{2}\.[0-9]{2}-[a-f0-9]+' | head -1 || echo "$CURRENT_VERSION")
|
||||||
|
|
||||||
# Compare versions
|
# Compare versions
|
||||||
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
|
if [ "$CURRENT_VERSION_NORMALIZED" = "$LATEST_VERSION" ]; then
|
||||||
log_success "Server is already up to date!"
|
log_success "Server is already up to date! ($LATEST_VERSION)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CURRENT_VERSION" = "unknown" ]; then
|
if [ "$CURRENT_VERSION" = "unknown" ]; then
|
||||||
log_warn "Could not compare versions. Proceeding with update..."
|
log_warn "Could not compare versions. Proceeding with update..."
|
||||||
else
|
else
|
||||||
log_info "Update available: $CURRENT_VERSION -> $LATEST_VERSION"
|
log_info "Update available: $CURRENT_VERSION_NORMALIZED -> $LATEST_VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask for confirmation
|
# Ask for confirmation
|
||||||
|
|
@ -244,6 +248,9 @@ do_update() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Track how the server was stopped so we can suggest how to restart it
|
||||||
|
STOPPED_VIA=""
|
||||||
|
|
||||||
# Check if server is running (systemd)
|
# Check if server is running (systemd)
|
||||||
if [ "$IS_SYSTEMCTL_AVAILABLE" = true ]; then
|
if [ "$IS_SYSTEMCTL_AVAILABLE" = true ]; then
|
||||||
if systemctl is-active --quiet hytale-server.service 2>/dev/null; then
|
if systemctl is-active --quiet hytale-server.service 2>/dev/null; then
|
||||||
|
|
@ -256,6 +263,7 @@ do_update() {
|
||||||
log_step "Stopping Hytale server..."
|
log_step "Stopping Hytale server..."
|
||||||
systemctl stop hytale-server.service || bail "Failed to stop server."
|
systemctl stop hytale-server.service || bail "Failed to stop server."
|
||||||
log_success "Server stopped."
|
log_success "Server stopped."
|
||||||
|
STOPPED_VIA="systemd"
|
||||||
else
|
else
|
||||||
bail "Cannot update while server is running. Please stop the server first."
|
bail "Cannot update while server is running. Please stop the server first."
|
||||||
fi
|
fi
|
||||||
|
|
@ -275,6 +283,7 @@ do_update() {
|
||||||
log_step "Stopping Docker container: $DOCKER_CONTAINER..."
|
log_step "Stopping Docker container: $DOCKER_CONTAINER..."
|
||||||
docker stop "$DOCKER_CONTAINER" || bail "Failed to stop Docker container."
|
docker stop "$DOCKER_CONTAINER" || bail "Failed to stop Docker container."
|
||||||
log_success "Docker container stopped."
|
log_success "Docker container stopped."
|
||||||
|
STOPPED_VIA="docker:$DOCKER_CONTAINER"
|
||||||
else
|
else
|
||||||
bail "Cannot update while server is running in Docker. Please stop the container first."
|
bail "Cannot update while server is running in Docker. Please stop the container first."
|
||||||
fi
|
fi
|
||||||
|
|
@ -294,6 +303,7 @@ do_update() {
|
||||||
log_step "Stopping Podman container: $PODMAN_CONTAINER..."
|
log_step "Stopping Podman container: $PODMAN_CONTAINER..."
|
||||||
podman stop "$PODMAN_CONTAINER" || bail "Failed to stop Podman container."
|
podman stop "$PODMAN_CONTAINER" || bail "Failed to stop Podman container."
|
||||||
log_success "Podman container stopped."
|
log_success "Podman container stopped."
|
||||||
|
STOPPED_VIA="podman:$PODMAN_CONTAINER"
|
||||||
else
|
else
|
||||||
bail "Cannot update while server is running in Podman. Please stop the container first."
|
bail "Cannot update while server is running in Podman. Please stop the container first."
|
||||||
fi
|
fi
|
||||||
|
|
@ -348,17 +358,33 @@ do_update() {
|
||||||
|
|
||||||
log_success "Server updated successfully!"
|
log_success "Server updated successfully!"
|
||||||
echo
|
echo
|
||||||
log_info "Updated from $CURRENT_VERSION to $LATEST_VERSION"
|
log_info "Updated from $CURRENT_VERSION_NORMALIZED to $LATEST_VERSION"
|
||||||
log_info "Backup of previous version saved to: $BACKUP_DIR"
|
log_info "Backup of previous version saved to: $BACKUP_DIR"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ "$IS_SYSTEMCTL_AVAILABLE" = true ]; then
|
# Show restart instructions based on how the server was stopped
|
||||||
log_info "To start the server, run:"
|
log_info "To start the server, run:"
|
||||||
echo -e " ${GREEN}sudo systemctl start hytale-server.service${NC}"
|
case "$STOPPED_VIA" in
|
||||||
else
|
systemd)
|
||||||
log_info "To start the server, run:"
|
echo -e " ${GREEN}sudo systemctl start hytale-server.service${NC}"
|
||||||
echo -e " ${GREEN}cd $INSTALL_PATH/Server && java -jar HytaleServer.jar --assets Assets.zip --disable-sentry${NC}"
|
;;
|
||||||
fi
|
docker:*)
|
||||||
|
CONTAINER_NAME="${STOPPED_VIA#docker:}"
|
||||||
|
echo -e " ${GREEN}docker start $CONTAINER_NAME${NC}"
|
||||||
|
;;
|
||||||
|
podman:*)
|
||||||
|
CONTAINER_NAME="${STOPPED_VIA#podman:}"
|
||||||
|
echo -e " ${GREEN}podman start $CONTAINER_NAME${NC}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Server wasn't running, show generic instructions
|
||||||
|
if [ "$IS_SYSTEMCTL_AVAILABLE" = true ] && [ -f "/etc/systemd/system/hytale-server.service" ]; then
|
||||||
|
echo -e " ${GREEN}sudo systemctl start hytale-server.service${NC}"
|
||||||
|
else
|
||||||
|
echo -e " ${GREEN}cd $INSTALL_PATH/Server && java -jar HytaleServer.jar --assets Assets.zip --disable-sentry${NC}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue