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