|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # Debian and Ubuntu Server Hardening Interactive Script |
4 | | -# Version: 0.78.4 | 2025-11-27 |
| 4 | +# Version: 0.78.5 | 2025-12-31 |
5 | 5 | # Changelog: |
| 6 | +# - v0.78.5: Switched to using nano as the default editor in .bashrc. |
6 | 7 | # - v0.78.4: Improved configure_swap to detect swap partitions vs files. |
7 | 8 | # Prevents 'fallocate' crashes on physical partitions by offering to disable them or skip. |
8 | 9 | # - v0.78.3: Update the summary to try to show the right environment detection based on finding personal VMs and cloud VPS. |
|
95 | 96 | set -euo pipefail |
96 | 97 |
|
97 | 98 | # --- Update Configuration --- |
98 | | -CURRENT_VERSION="0.78.4" |
| 99 | +CURRENT_VERSION="0.78.5" |
99 | 100 | SCRIPT_URL="https://raw.githubusercontent.com/buildplan/du_setup/refs/heads/main/du_setup.sh" |
100 | 101 | CHECKSUM_URL="${SCRIPT_URL}.sha256" |
101 | 102 |
|
@@ -251,7 +252,7 @@ print_header() { |
251 | 252 | printf '%s\n' "${CYAN}╔═════════════════════════════════════════════════════════════════╗${NC}" |
252 | 253 | printf '%s\n' "${CYAN}║ ║${NC}" |
253 | 254 | printf '%s\n' "${CYAN}║ DEBIAN/UBUNTU SERVER SETUP AND HARDENING SCRIPT ║${NC}" |
254 | | - printf '%s\n' "${CYAN}║ v0.78.4 | 2025-11-27 ║${NC}" |
| 255 | + printf '%s\n' "${CYAN}║ v0.78.5 | 2025-12-31 ║${NC}" |
255 | 256 | printf '%s\n' "${CYAN}║ ║${NC}" |
256 | 257 | printf '%s\n' "${CYAN}╚═════════════════════════════════════════════════════════════════╝${NC}" |
257 | 258 | printf '\n' |
@@ -1101,8 +1102,8 @@ configure_custom_bashrc() { |
1101 | 1102 | if ! cat > "$temp_source_bashrc" <<'EOF' |
1102 | 1103 | # shellcheck shell=bash |
1103 | 1104 | # =================================================================== |
1104 | | -# Universal Portable .bashrc for Modern Terminals |
1105 | | -# Optimized for Debian/Ubuntu servers with multi-terminal support |
| 1105 | +# Universal Portable .bashrc |
| 1106 | +# For Debian/Ubuntu servers with multi-terminal support |
1106 | 1107 | # =================================================================== |
1107 | 1108 |
|
1108 | 1109 | # If not running interactively, don't do anything. |
@@ -1260,12 +1261,12 @@ __bash_prompt_command() { |
1260 | 1261 | PROMPT_COMMAND=__bash_prompt_command |
1261 | 1262 |
|
1262 | 1263 | # --- Editor Configuration --- |
1263 | | -if command -v vim &>/dev/null; then |
1264 | | - export EDITOR=vim |
1265 | | - export VISUAL=vim |
1266 | | -elif command -v nano &>/dev/null; then |
| 1264 | +if command -v nano &>/dev/null; then |
1267 | 1265 | export EDITOR=nano |
1268 | 1266 | export VISUAL=nano |
| 1267 | +elif command -v vim &>/dev/null; then |
| 1268 | + export EDITOR=vim |
| 1269 | + export VISUAL=vim |
1269 | 1270 | else |
1270 | 1271 | export EDITOR=vi |
1271 | 1272 | export VISUAL=vi |
@@ -1671,13 +1672,14 @@ alias ltr='ls -alFhtr' # Sort by modification time, oldest first |
1671 | 1672 | alias lS='ls -alFhS' # Sort by size, largest first |
1672 | 1673 |
|
1673 | 1674 | # Last command with sudo |
1674 | | -alias please='sudo $(history -p !!)' |
| 1675 | +alias please='eval sudo "$(history -p !!)"' |
1675 | 1676 |
|
1676 | 1677 | # Safety aliases to prompt before overwriting. |
1677 | 1678 | alias rm='rm -i' |
1678 | 1679 | alias cp='cp -i' |
1679 | 1680 | alias mv='mv -i' |
1680 | 1681 | alias ln='ln -i' |
| 1682 | +alias mkdir='mkdir -p' |
1681 | 1683 |
|
1682 | 1684 | # Convenience & Navigation aliases. |
1683 | 1685 | alias ..='cd ..' |
@@ -1727,7 +1729,10 @@ alias pscpu='ps auxf | sort -nr -k 3 | head -10' |
1727 | 1729 | alias top10='ps aux --sort=-%mem | head -n 11' |
1728 | 1730 |
|
1729 | 1731 | # Quick network info. |
1730 | | -alias myip='curl -s ifconfig.me || curl -s icanhazip.com' # Alternatives: api.ipify.org, icanhazip.co |
| 1732 | +# Get public IP with timeouts (3s), fallbacks, and newline formatting |
| 1733 | +alias myip='curl -s --connect-timeout 3 ip.me || curl -s --connect-timeout 3 icanhazip.com || curl -s --connect-timeout 3 ifconfig.me; echo' |
| 1734 | +alias myip4='curl -4 -s --connect-timeout 3 ip.me || curl -4 -s --connect-timeout 3 icanhazip.com || curl -4 -s --connect-timeout 3 ifconfig.me; echo' |
| 1735 | +alias myip6='curl -6 -s --connect-timeout 3 ip.me || curl -6 -s --connect-timeout 3 icanhazip.com || curl -6 -s --connect-timeout 3 ifconfig.me; echo' |
1731 | 1736 | # Show local IP address(es), excluding loopback. |
1732 | 1737 | localip() { |
1733 | 1738 | ip -4 addr | awk '/inet/ {print $2}' | cut -d/ -f1 | grep -v '127.0.0.1' |
@@ -1765,6 +1770,7 @@ if command -v docker &>/dev/null; then |
1765 | 1770 | alias d='docker' |
1766 | 1771 | alias dps='docker ps' |
1767 | 1772 | alias dpsa='docker ps -a' |
| 1773 | + alias dpsn="docker ps --format '{{.Names}}'" |
1768 | 1774 | alias dpsq='docker ps -q' |
1769 | 1775 | alias di='docker images' |
1770 | 1776 | alias dv='docker volume ls' |
|
0 commit comments