Update system information and check IPv6 address.
This commit is contained in:
parent
1f275b3c64
commit
b53a10d085
|
@ -6,15 +6,15 @@ apt_get_quiet install bind9-host sed netcat-openbsd
|
||||||
# The user might have chosen a name that was previously in use by a spammer
|
# The user might have chosen a name that was previously in use by a spammer
|
||||||
# and will not be able to reliably send mail. Do this after any automatic
|
# and will not be able to reliably send mail. Do this after any automatic
|
||||||
# choices made above.
|
# choices made above.
|
||||||
if host $PRIMARY_HOSTNAME.dbl.spamhaus.org > /dev/null; then
|
if host "$PRIMARY_HOSTNAME.dbl.spamhaus.org" > /dev/null; then
|
||||||
echo
|
echo >&2
|
||||||
echo "The hostname you chose '$PRIMARY_HOSTNAME' is listed in the"
|
echo "The hostname you chose '$PRIMARY_HOSTNAME' is listed in the" >&2
|
||||||
echo "Spamhaus Domain Block List. See http://www.spamhaus.org/dbl/"
|
echo "Spamhaus Domain Block List. See http://www.spamhaus.org/dbl/" >&2
|
||||||
echo "and http://www.spamhaus.org/query/domain/$PRIMARY_HOSTNAME."
|
echo "and http://www.spamhaus.org/query/domain/$PRIMARY_HOSTNAME." >&2
|
||||||
echo
|
echo >&2
|
||||||
echo "You will not be able to send mail using this domain name, so"
|
echo "You will not be able to send mail using this domain name, so" >&2
|
||||||
echo "setup cannot continue."
|
echo "setup cannot continue." >&2
|
||||||
echo
|
echo >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -22,22 +22,52 @@ fi
|
||||||
# The user might have ended up on an IP address that was previously in use
|
# The user might have ended up on an IP address that was previously in use
|
||||||
# by a spammer, or the user may be deploying on a residential network. We
|
# by a spammer, or the user may be deploying on a residential network. We
|
||||||
# will not be able to reliably send mail in these cases.
|
# will not be able to reliably send mail in these cases.
|
||||||
REVERSED_IPV4=$(echo $PUBLIC_IP | sed "s/\([0-9]*\).\([0-9]*\).\([0-9]*\).\([0-9]*\)/\4.\3.\2.\1/")
|
# Adapted from: https://github.com/tdulcet/Remote-Servers-Status/blob/master/status.sh
|
||||||
if host $REVERSED_IPV4.zen.spamhaus.org > /dev/null; then
|
REVERSED_IPV4=$(echo "$PUBLIC_IP" | awk -F'.' '{for(i=NF;i>0;i--) printf "%s%s",$i,(i==1?"\n":".")}')
|
||||||
echo
|
if host "$REVERSED_IPV4.zen.spamhaus.org" > /dev/null; then
|
||||||
echo "The IP address $PUBLIC_IP is listed in the Spamhaus Block List."
|
output=$(dig +short txt "$REVERSED_IPV4.zen.spamhaus.org" 2>&1) && [[ -n "$output" ]] && mapfile -t reasons < <(echo "$output" | grep -v '^;')
|
||||||
echo "See http://www.spamhaus.org/query/ip/$PUBLIC_IP."
|
echo >&2
|
||||||
echo
|
echo "The IP address $PUBLIC_IP is listed in the Spamhaus Block List." >&2
|
||||||
echo "You will not be able to send mail using this machine, so setup"
|
if [[ -n "$reasons" ]]; then
|
||||||
echo "cannot continue."
|
echo "Reason: ${reasons[*]}" >&2
|
||||||
echo
|
fi
|
||||||
echo "Associate a different IP address with this machine if possible."
|
echo "See http://www.spamhaus.org/query/ip/$PUBLIC_IP." >&2
|
||||||
echo "Many residential network IP addresses are listed, so Mail-in-a-Box"
|
echo >&2
|
||||||
echo "typically cannot be used on a residential Internet connection."
|
echo "You will not be able to send mail using this machine, so setup" >&2
|
||||||
echo
|
echo "cannot continue." >&2
|
||||||
|
echo >&2
|
||||||
|
echo "Associate a different IP address with this machine if possible." >&2
|
||||||
|
echo "Many residential network IP addresses are listed, so Mail-in-a-Box" >&2
|
||||||
|
echo "typically cannot be used on a residential Internet connection." >&2
|
||||||
|
echo >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Stop if the IPv6 address is listed in the ZEN Spamhouse Block List.
|
||||||
|
# Adapted from: https://github.com/tdulcet/Remote-Servers-Status/blob/master/status.sh
|
||||||
|
if [ -n "$PUBLIC_IPV6" ]; then
|
||||||
|
# Expand and reverse IPv6 address, adapted from: https://gist.github.com/lsowen/4447d916fd19cbb7fce4
|
||||||
|
REVERSED_IPV6=$(echo "$PUBLIC_IPV6" | awk -F: 'BEGIN{OFS="";}{addCount = 9 - NF; for(i=1;i<=NF;i++) {if(length($i) == 0) {for(j=1;j<=addCount;j++) {$i = ($i "0000");}} else{$i = substr(("0000" $i), length($i)+5-4);}}; print}' | awk -F '' 'BEGIN{OFS=".";}{for(i=NF;i>0;i--) printf "%s%s",$i,(i==1?"\n":".")}')
|
||||||
|
if host "$REVERSED_IPV6.zen.spamhaus.org" > /dev/null; then
|
||||||
|
output=$(dig +short txt "$REVERSED_IPV6.zen.spamhaus.org" 2>&1) && [[ -n "$output" ]] && mapfile -t reasons < <(echo "$output" | grep -v '^;')
|
||||||
|
echo >&2
|
||||||
|
echo "The IP address $PUBLIC_IPV6 is listed in the Spamhaus Block List." >&2
|
||||||
|
if [[ -n "$reasons" ]]; then
|
||||||
|
echo "Reason: ${reasons[*]}" >&2
|
||||||
|
fi
|
||||||
|
echo "See http://www.spamhaus.org/query/ip/$PUBLIC_IPV6." >&2
|
||||||
|
echo >&2
|
||||||
|
echo "You will not be able to send mail using this machine, so setup" >&2
|
||||||
|
echo "cannot continue." >&2
|
||||||
|
echo >&2
|
||||||
|
echo "Associate a different IP address with this machine if possible." >&2
|
||||||
|
echo "Many residential network IP addresses are listed, so Mail-in-a-Box" >&2
|
||||||
|
echo "typically cannot be used on a residential Internet connection." >&2
|
||||||
|
echo >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Stop if we cannot make an outbound connection on port 25. Many residential
|
# Stop if we cannot make an outbound connection on port 25. Many residential
|
||||||
# networks block outbound port 25 to prevent their network from sending spam.
|
# networks block outbound port 25 to prevent their network from sending spam.
|
||||||
# See if we can reach one of Google's MTAs with a 5-second timeout.
|
# See if we can reach one of Google's MTAs with a 5-second timeout.
|
||||||
|
|
|
@ -25,7 +25,8 @@ if ! echo "$ID" | grep -iq "ubuntu" || ! echo "$VERSION_ID" | grep -iq "18.04";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for the Windows Subsystem for Linux (WSL)
|
# Check for the Windows Subsystem for Linux (WSL)
|
||||||
if uname -r | grep -iq "microsoft"; then
|
KERNEL=$(uname -r)
|
||||||
|
if echo "$KERNEL" | grep -iq "microsoft"; then
|
||||||
echo "Warning: The Windows Subsystem for Linux (WSL) is not yet fully supported by this script."
|
echo "Warning: The Windows Subsystem for Linux (WSL) is not yet fully supported by this script."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ address, so we're suggesting $DEFAULT_PRIMARY_HOSTNAME.
|
||||||
RE='^.+\.localdomain$'
|
RE='^.+\.localdomain$'
|
||||||
# Regular expressions to check if the hostname is a valid FQDN
|
# Regular expressions to check if the hostname is a valid FQDN
|
||||||
RE1='^.{4,253}$'
|
RE1='^.{4,253}$'
|
||||||
RE2='^([[:alnum:]][[:alnum:]\-]{0,61}[[:alnum:]]\.)+[a-zA-Z]{2,63}$'
|
RE2='^((xn--)?[[:alnum:]][[:alnum:]\-]{0,61}[[:alnum:]]\.)+(xn--)?[a-zA-Z]{2,63}$'
|
||||||
if [ -z "$PRIMARY_HOSTNAME" ]; then
|
if [ -z "$PRIMARY_HOSTNAME" ]; then
|
||||||
# user hit ESC/cancel
|
# user hit ESC/cancel
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -203,18 +203,21 @@ if [ -z "${STORAGE_ROOT:-}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show the configuration, since the user may have not entered it manually.
|
# Show the configuration, since the user may have not entered it manually.
|
||||||
|
# Adapted from: https://github.com/tdulcet/Linux-System-Information/blob/master/info.sh
|
||||||
echo -e "\nLinux Distribution:\t\t${PRETTY_NAME:-$ID-$VERSION_ID}"
|
echo -e "\nLinux Distribution:\t\t${PRETTY_NAME:-$ID-$VERSION_ID}"
|
||||||
CPU=( $(sed -n 's/^model name[[:space:]]*: *//p' /proc/cpuinfo | uniq) )
|
echo -e "Linux Kernel:\t\t\t$KERNEL"
|
||||||
|
mapfile -t CPU < <(sed -n 's/^model name[[:space:]]*: *//p' /proc/cpuinfo | uniq)
|
||||||
if [ -n "$CPU" ]; then
|
if [ -n "$CPU" ]; then
|
||||||
echo -e "Processor (CPU):\t\t${CPU[*]}"
|
echo -e "Processor (CPU):\t\t${CPU[*]}"
|
||||||
fi
|
fi
|
||||||
CPU_CORES=$(nproc --all)
|
CPU_THREADS=$(nproc --all)
|
||||||
echo -e "CPU Cores:\t\t\t$CPU_CORES"
|
CPU_CORES=$(( CPU_THREADS / $(lscpu | grep -i '^thread(s) per core' | sed -n 's/^.\+:[[:blank:]]*//p') ))
|
||||||
|
echo -e "CPU Cores/Threads:\t\t$CPU_CORES/$CPU_THREADS"
|
||||||
echo -e "Architecture:\t\t\t$HOSTTYPE (${ARCHITECTURE}-bit)"
|
echo -e "Architecture:\t\t\t$HOSTTYPE (${ARCHITECTURE}-bit)"
|
||||||
echo -e "Total memory (RAM):\t\t$(printf "%'d" $((TOTAL_PHYSICAL_MEM / 1024))) MiB ($(printf "%'d" $((((TOTAL_PHYSICAL_MEM * 1024) / 1000) / 1000))) MB)"
|
echo -e "Total memory (RAM):\t\t$(printf "%'d" $((TOTAL_PHYSICAL_MEM / 1024))) MiB ($(printf "%'d" $((((TOTAL_PHYSICAL_MEM * 1024) / 1000) / 1000))) MB)"
|
||||||
echo -e "Total swap space:\t\t$(printf "%'d" $((TOTAL_SWAP / 1024))) MiB ($(printf "%'d" $((((TOTAL_SWAP * 1024) / 1000) / 1000))) MB)"
|
echo -e "Total swap space:\t\t$(printf "%'d" $((TOTAL_SWAP / 1024))) MiB ($(printf "%'d" $((((TOTAL_SWAP * 1024) / 1000) / 1000))) MB)"
|
||||||
if command -v lspci >/dev/null; then
|
if command -v lspci >/dev/null; then
|
||||||
GPU=( $(lspci 2>/dev/null | grep -i 'vga\|3d\|2d' | sed -n 's/^.*: //p') )
|
mapfile -t GPU < <(lspci 2>/dev/null | grep -i 'vga\|3d\|2d' | sed -n 's/^.*: //p')
|
||||||
fi
|
fi
|
||||||
if [ -n "$GPU" ]; then
|
if [ -n "$GPU" ]; then
|
||||||
echo -e "Graphics Processor (GPU):\t${GPU[*]}"
|
echo -e "Graphics Processor (GPU):\t${GPU[*]}"
|
||||||
|
@ -239,7 +242,7 @@ else
|
||||||
echo -e "Private IP Address:\t\t$PRIVATE_IP"
|
echo -e "Private IP Address:\t\t$PRIVATE_IP"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
TIME_ZONE=$(timedatectl 2>/dev/null | grep -i 'time zone\|timezone' | sed -n 's/^.*: //p')
|
TIME_ZONE=$(timedatectl 2>/dev/null | grep -i 'time zone:\|timezone:' | sed -n 's/^.*: //p')
|
||||||
echo -e "Time zone:\t\t\t$TIME_ZONE\n"
|
echo -e "Time zone:\t\t\t$TIME_ZONE\n"
|
||||||
if command -v systemd-detect-virt >/dev/null && CONTAINER=$(systemd-detect-virt -c); then
|
if command -v systemd-detect-virt >/dev/null && CONTAINER=$(systemd-detect-virt -c); then
|
||||||
echo -e "Virtualization container:\t$CONTAINER\n"
|
echo -e "Virtualization container:\t$CONTAINER\n"
|
||||||
|
|
Loading…
Reference in New Issue