|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # Debian and Ubuntu Server Hardening Interactive Script |
4 | | -# Version: 0.80.4 | 2026-03-09 |
| 4 | +# Version: 0.80.5 | 2026-03-26 |
5 | 5 | # 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. |
6 | 8 | # - v0.80.4: Warn and finish the script if Docker, Tailscale and Netbird fail to install properly. |
7 | 9 | # - v0.80.3: Warn about password-less sudo and offer to generate password for the user if they choose to do so. |
8 | 10 | # Improve SSH service detection for Debian systems. |
|
106 | 108 | set -euo pipefail |
107 | 109 |
|
108 | 110 | # --- Update Configuration --- |
109 | | -CURRENT_VERSION="0.80.4" |
| 111 | +CURRENT_VERSION="0.80.5" |
110 | 112 | SCRIPT_URL="https://raw.githubusercontent.com/buildplan/du_setup/refs/heads/main/du_setup.sh" |
111 | 113 | CHECKSUM_URL="${SCRIPT_URL}.sha256" |
112 | 114 |
|
@@ -270,7 +272,7 @@ print_header() { |
270 | 272 | printf '%s\n' "${CYAN}╔═════════════════════════════════════════════════════════════════╗${NC}" |
271 | 273 | printf '%s\n' "${CYAN}║ ║${NC}" |
272 | 274 | 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}" |
274 | 276 | printf '%s\n' "${CYAN}║ ║${NC}" |
275 | 277 | printf '%s\n' "${CYAN}╚═════════════════════════════════════════════════════════════════╝${NC}" |
276 | 278 | printf '\n' |
@@ -2607,7 +2609,7 @@ validate_ssh_key() { |
2607 | 2609 |
|
2608 | 2610 | validate_timezone() { |
2609 | 2611 | local tz="$1" |
2610 | | - [[ -e "/usr/share/zoneinfo/$tz" ]] |
| 2612 | + [[ -f "/usr/share/zoneinfo/$tz" ]] |
2611 | 2613 | } |
2612 | 2614 |
|
2613 | 2615 | validate_ufw_port() { |
@@ -2882,9 +2884,9 @@ collect_config() { |
2882 | 2884 | if validate_hostname "$SERVER_NAME"; then break; else print_error "Invalid hostname."; fi |
2883 | 2885 | done |
2884 | 2886 | 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}" |
2886 | 2888 | # --- 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) |
2888 | 2890 | local PROMPT_DEFAULT_PORT=${PREVIOUS_SSH_PORT:-2222} |
2889 | 2891 | while true; do |
2890 | 2892 | read -rp "$(printf '%s' "${CYAN}Enter custom SSH port (1024-65535) [$PROMPT_DEFAULT_PORT]: ${NC}")" SSH_PORT |
|
0 commit comments