1
0
mirror of synced 2024-11-22 04:56:03 +03:00

Add CentOS 9

- Add support for version 9 of CentOS Stream, RHEL, Rocky Linux
  and AlmaLinux.
This commit is contained in:
hwdsl2 2022-07-30 02:59:49 -05:00
parent 066cb14e14
commit 10d54262fb
8 changed files with 59 additions and 35 deletions

View File

@ -42,16 +42,12 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file" \
|| grep -qs "release 9" "$rh_file"; then
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn
os_ver=2
else
os_type=$(lsb_release -si 2>/dev/null)
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
@ -77,14 +73,6 @@ EOF
exit 1
;;
esac
if [ "$os_type" = "alpine" ]; then
os_ver=$(. /etc/os-release && printf '%s' "$VERSION_ID" | cut -d '.' -f 1,2)
if [ "$os_ver" != "3.15" ] && [ "$os_ver" != "3.16" ]; then
exiterr "This script only supports Alpine Linux 3.15/3.16."
fi
else
os_ver=$(sed 's/\..*//' /etc/debian_version | tr -dc 'A-Za-z0-9')
fi
fi
}

View File

@ -53,13 +53,16 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn
os_ver=2
@ -151,7 +154,7 @@ confirm_or_abort() {
show_header() {
cat <<'EOF'
IKEv2 Script Copyright (c) 2020-2022 Lin Song 27 Jul 2022
IKEv2 Script Copyright (c) 2020-2022 Lin Song 31 Jul 2022
EOF
}

View File

@ -75,16 +75,22 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
exiterr "CentOS Linux 8 is EOL and not supported."
fi
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
if [ "$os_type" = "ol" ]; then
exiterr "Oracle Linux 9 is not supported."
fi
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn
os_ver=2

View File

@ -40,7 +40,8 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file"; then
if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file" \
|| grep -qs "release 9" "$rh_file"; then
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
@ -272,8 +273,12 @@ update_iptables_rules() {
else
nft_bk=$(find /etc/sysconfig -maxdepth 1 -name 'nftables.conf.old-*-*-*-*_*_*' -print0 \
| xargs -r -0 ls -1 -t | head -1)
diff_count=24
if grep -qs "release 9" /etc/redhat-release; then
diff_count=38
fi
if [ -f "$nft_bk" ] \
&& [ "$(diff -y --suppress-common-lines "$IPT_FILE" "$nft_bk" | wc -l)" = "24" ]; then
&& [ "$(diff -y --suppress-common-lines "$IPT_FILE" "$nft_bk" | wc -l)" = "$diff_count" ]; then
bigecho "Restoring nftables rules..."
conf_bk "$IPT_FILE"
/bin/cp -f "$nft_bk" "$IPT_FILE" && /bin/rm -f "$nft_bk"

View File

@ -43,16 +43,19 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
exiterr "CentOS Linux 8 is EOL and not supported."
fi
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn
os_ver=2

View File

@ -46,16 +46,19 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
exiterr "CentOS Linux 8 is EOL and not supported."
fi
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
else
cat 1>&2 <<'EOF'
Error: This script only supports one of the following OS:

View File

@ -75,16 +75,22 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
exiterr "CentOS Linux 8 is EOL and not supported."
fi
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
if [ "$os_type" = "ol" ]; then
exiterr "Oracle Linux 9 is not supported."
fi
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
os_type=amzn
os_ver=2

View File

@ -80,16 +80,22 @@ check_os() {
os_type=rhel
fi
[ -f /etc/oracle-release ] && os_type=ol
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if grep -qs "release 7" "$rh_file"; then
os_ver=7
elif grep -qs "release 8" "$rh_file"; then
os_ver=8
grep -qi stream "$rh_file" && os_ver=8s
grep -qi rocky "$rh_file" && os_type=rocky
grep -qi alma "$rh_file" && os_type=alma
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
exiterr "CentOS Linux 8 is EOL and not supported."
fi
elif grep -qs "release 9" "$rh_file"; then
os_ver=9
grep -qi stream "$rh_file" && os_ver=9s
if [ "$os_type" = "ol" ]; then
exiterr "Oracle Linux 9 is not supported."
fi
else
cat 1>&2 <<'EOF'
Error: This script only supports one of the following OS:
@ -218,11 +224,14 @@ install_vpn_pkgs_1() {
rp1="$erp=epel"
rp2="$erp=*server-*optional*"
rp3="$erp=*releases-optional*"
if [ "$os_type" = "ol" ] && [ "$os_ver" = "8" ]; then
rp1="$erp=ol8_developer_EPEL"
fi
if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then
rp3="$erp=ol7_optional_latest"
if [ "$os_type" = "ol" ]; then
if [ "$os_ver" = "9" ]; then
rp1="$erp=ol9_developer_EPEL"
elif [ "$os_ver" = "8" ]; then
rp1="$erp=ol8_developer_EPEL"
else
rp3="$erp=ol7_optional_latest"
fi
fi
(
set -x
@ -255,7 +264,8 @@ install_vpn_pkgs_3() {
set -x
yum -y -q install $p1 $p2 >/dev/null
) || exiterr2
if systemctl is-active --quiet firewalld \
if [ "$os_ver" = "9" ] || [ "$os_ver" = "9s" ] \
|| systemctl is-active --quiet firewalld \
|| systemctl is-active --quiet nftables \
|| grep -qs "hwdsl2 VPN script" /etc/sysconfig/nftables.conf; then
use_nft=1