Skip to content

Commit d3dee07

Browse files
authored
Merge pull request #112 from buildplan/111-silent-crash-after-incorrect-timezone
fix: silent crash after incorrect timezone
2 parents 02dc8fd + 4eb727e commit d3dee07

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
-----
99

10-
**Version:** v0.80.4
10+
**Version:** v0.80.5
1111

12-
**Last Updated:** 2026-03-09
12+
**Last Updated:** 2026-03-26
1313

1414
**Compatible With:**
1515

@@ -88,12 +88,12 @@ sha256sum du_setup.sh
8888

8989
Compare the output hash to the one below. They must match exactly.
9090

91-
`f32dafe3170045b35cf3b20fe00b6689e192f2bfaa1b6879277b42ca40854bd5`
91+
`f6c7047a052fc795612dadc6e72871dc756c30c87698a302fc7c46c1e3582bda`
9292

9393
Or echo the hash to check, it should output: `du_setup.sh: OK`
9494

9595
```bash
96-
echo f32dafe3170045b35cf3b20fe00b6689e192f2bfaa1b6879277b42ca40854bd5 du_setup.sh | sha256sum --check
96+
echo f6c7047a052fc795612dadc6e72871dc756c30c87698a302fc7c46c1e3582bda du_setup.sh | sha256sum --check
9797
```
9898

9999
### 3. Run the Script

du_setup.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22

33
# Debian and Ubuntu Server Hardening Interactive Script
4-
# Version: 0.80.4 | 2026-03-09
4+
# Version: 0.80.5 | 2026-03-26
55
# Changelog:
6+
# - v0.80.5: Fixed a crash in timezone validation by checking for files (-f) instead of directories.
7+
# Resolved unexpected set -e terminations during 'pretty hostname' assignment and SSH port detection.
68
# - v0.80.4: Warn and finish the script if Docker, Tailscale and Netbird fail to install properly.
79
# - v0.80.3: Warn about password-less sudo and offer to generate password for the user if they choose to do so.
810
# Improve SSH service detection for Debian systems.
@@ -106,7 +108,7 @@
106108
set -euo pipefail
107109

108110
# --- Update Configuration ---
109-
CURRENT_VERSION="0.80.4"
111+
CURRENT_VERSION="0.80.5"
110112
SCRIPT_URL="https://raw.githubusercontent.com/buildplan/du_setup/refs/heads/main/du_setup.sh"
111113
CHECKSUM_URL="${SCRIPT_URL}.sha256"
112114

@@ -270,7 +272,7 @@ print_header() {
270272
printf '%s\n' "${CYAN}╔═════════════════════════════════════════════════════════════════╗${NC}"
271273
printf '%s\n' "${CYAN}║ ║${NC}"
272274
printf '%s\n' "${CYAN}║ DEBIAN/UBUNTU SERVER SETUP AND HARDENING SCRIPT ║${NC}"
273-
printf '%s\n' "${CYAN}║ v0.80.4 | 2026-03-09${NC}"
275+
printf '%s\n' "${CYAN}║ v0.80.5 | 2026-03-26${NC}"
274276
printf '%s\n' "${CYAN}║ ║${NC}"
275277
printf '%s\n' "${CYAN}╚═════════════════════════════════════════════════════════════════╝${NC}"
276278
printf '\n'
@@ -2607,7 +2609,7 @@ validate_ssh_key() {
26072609

26082610
validate_timezone() {
26092611
local tz="$1"
2610-
[[ -e "/usr/share/zoneinfo/$tz" ]]
2612+
[[ -f "/usr/share/zoneinfo/$tz" ]]
26112613
}
26122614

26132615
validate_ufw_port() {
@@ -2882,9 +2884,9 @@ collect_config() {
28822884
if validate_hostname "$SERVER_NAME"; then break; else print_error "Invalid hostname."; fi
28832885
done
28842886
read -rp "$(printf '%s' "${CYAN}Enter a 'pretty' hostname (optional): ${NC}")" PRETTY_NAME
2885-
[[ -z "$PRETTY_NAME" ]] && PRETTY_NAME="$SERVER_NAME"
2887+
PRETTY_NAME="${PRETTY_NAME:-$SERVER_NAME}"
28862888
# --- SSH Port Detection ---
2887-
PREVIOUS_SSH_PORT=$(ss -tlpn | grep -E 'sshd|ssh\.socket' | awk '{print $4}' | grep -oP ':\K\d+' | grep -vE '^60[1-9][0-9]$' | head -n 1)
2889+
PREVIOUS_SSH_PORT=$(ss -tlpn | grep -E 'sshd|ssh\.socket' | awk '{print $4}' | grep -oP ':\K\d+' | grep -vE '^60[1-9][0-9]$' | head -n 1 || true)
28882890
local PROMPT_DEFAULT_PORT=${PREVIOUS_SSH_PORT:-2222}
28892891
while true; do
28902892
read -rp "$(printf '%s' "${CYAN}Enter custom SSH port (1024-65535) [$PROMPT_DEFAULT_PORT]: ${NC}")" SSH_PORT

du_setup.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f32dafe3170045b35cf3b20fe00b6689e192f2bfaa1b6879277b42ca40854bd5 du_setup.sh
1+
f6c7047a052fc795612dadc6e72871dc756c30c87698a302fc7c46c1e3582bda du_setup.sh

0 commit comments

Comments
 (0)