From b9a1e6b3db0fec857fb449ade845489cb8ae1cb6 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 12 Jun 2020 15:55:59 +0200 Subject: [PATCH] Minor changes to snippets/tpl.001.basics.sh --- snippets/tpl.001.basics.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/snippets/tpl.001.basics.sh b/snippets/tpl.001.basics.sh index 86473d5..a344967 100644 --- a/snippets/tpl.001.basics.sh +++ b/snippets/tpl.001.basics.sh @@ -10,15 +10,36 @@ echo if [[ -z "${hostname}" ]] ; then hostname="template.pixelpark.com" fi -IP_ADDRESS_ETH0=$( host "${hostname}" | sed -e 's/.*has address[ ][ ]*//' ) -DOMAIN=$( echo "${hostname}" | cut -d. -f2,3 ) -SIMPLE_HOSTNAME=$( echo "${hostname}" | cut -d. -f1 ) + +DEVNAME_ETH0=$( ip -oneline link show | \ + grep -v ' lo: ' | \ + head -n 1 | \ + awk '{print $2}' | \ + sed -e 's/:$//' ) +IP_ADDRESS_ETH0=$( ip -oneline addr show dev "${DEVNAME_ETH0}" | \ + grep ' inet ' | \ + head -n 1 | \ + awk '{print $4}' | \ + sed -e 's|/.*||' ) +GATEWAY=$( ip -oneline route show | grep ^default | head -n 1 | awk '{print $3}' ) +DOMAIN=$( echo "${hostname}" | sed -e 's/^[^\.]*\.//' ) +SIMPLE_HOSTNAME=$( echo "${hostname}" | sed -e 's/\..*//' ) if [[ -z "${ip_address_eth0}" ]] ; then ip_address_eth0="${IP_ADDRESS_ETH0}" fi -POSTFIX_MYORIGIN='pixelpark.net' +if [[ -z "${gateway}" ]] ; then + gateway="${GATEWAY}" +fi + +if [[ -z "${mac_address_eth0}" ]] ; then + mac_address_eth0=$( ip -oneline link show dev "${DEVNAME_ETH0}" | \ + grep -P -o 'link/ether\s+\S+' | \ + awk '{print $2}' ) +fi + +POSTFIX_MYORIGIN='pixelpark.com' POSTFIX_RELAYHOST='[mx.pixelpark.com]' ERROR_POINTER="/root/postinst-error.txt" -- 2.39.5