install_postfix_base.sh: change function dectec_os to dectect_os_1.

This commit is contained in:
Christoph 2023-11-15 18:36:51 +01:00
parent b717e88130
commit d5d3bddb8c

View File

@ -84,18 +84,17 @@ blank_line() {
fi
}
detect_os () {
detect_os_1 () {
if $(which lsb_release > /dev/null 2>&1) ; then
DIST="$(lsb_release -i | awk '{print tolower($3)}')"
DIST_VERSION="$(lsb_release -r | awk '{print tolower($2)}')"
DIST_CODENAME="$(lsb_release -c | awk '{print tolower($2)}')"
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
if [[ "$DIST" = "debian" ]]; then
if $(echo "$DIST_VERSION" | grep -q '\.') ; then
DIST_VERSION=$(echo "$DIST_VERSION" | cut --delimiter='.' -f1)
if [[ "$os_dist" = "debian" ]]; then
if $(echo "$os_version" | grep -q '\.') ; then
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
fi
fi
@ -103,14 +102,14 @@ detect_os () {
. /etc/os-release
DIST=$ID
DIST_VERSION=${VERSION_ID}
os_dist=$ID
os_version=${VERSION_ID}
fi
# remove whitespace from DIST and DIST_VERSION
DIST="${DIST// /}"
DIST_VERSION="${DIST_VERSION// /}"
# remove whitespace from os_dist and os_version
os_dist="${os_dist// /}"
os_version="${os_version// /}"
}
@ -157,7 +156,7 @@ fi
blank_line
echononl "Detect distribution/release of running OS.."
detect_os > /dev/null 2>&1
detect_os_1 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo_failed
else
@ -1047,7 +1046,7 @@ fi
## -
echononl " Generate DH key length=512 \"/etc/postfix/ssl/dh_512.pem\""
if [[ ! -f /etc/postfix/ssl/dh_512.pem ]]; then
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
@ -1058,7 +1057,7 @@ if [[ ! -f /etc/postfix/ssl/dh_512.pem ]]; then
echo_failed
fi
else
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_512.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
@ -1075,7 +1074,7 @@ else
fi
echononl " Generate DH key length=1024 \"/etc/postfix/ssl/dh_1024.pem\""
if [[ ! -f /etc/postfix/ssl/dh_1024.pem ]]; then
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
@ -1086,7 +1085,7 @@ if [[ ! -f /etc/postfix/ssl/dh_1024.pem ]]; then
echo_failed
fi
else
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_1024.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
@ -1103,7 +1102,7 @@ else
fi
echononl " Generate DH key length=2048 \"/etc/postfix/ssl/dh_2048.pem\""
if [[ ! -f /etc/postfix/ssl/dh_2048.pem ]]; then
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
@ -1114,7 +1113,7 @@ if [[ ! -f /etc/postfix/ssl/dh_2048.pem ]]; then
echo_failed
fi
else
if [[ $DIST_VERSION -gt 11 ]] ; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_2048.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then