Add CentOS 9
- Add support for version 9 of CentOS Stream, RHEL, Rocky Linux and AlmaLinux.
This commit is contained in:
parent
066cb14e14
commit
10d54262fb
@ -42,16 +42,12 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -f /etc/oracle-release ] && os_type=ol
|
||||||
if grep -qs "release 7" "$rh_file"; then
|
if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file" \
|
||||||
os_ver=7
|
|| grep -qs "release 9" "$rh_file"; then
|
||||||
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 rocky "$rh_file" && os_type=rocky
|
||||||
grep -qi alma "$rh_file" && os_type=alma
|
grep -qi alma "$rh_file" && os_type=alma
|
||||||
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
os_type=amzn
|
os_type=amzn
|
||||||
os_ver=2
|
|
||||||
else
|
else
|
||||||
os_type=$(lsb_release -si 2>/dev/null)
|
os_type=$(lsb_release -si 2>/dev/null)
|
||||||
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
||||||
@ -77,14 +73,6 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,13 +53,16 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
grep -qi stream "$rh_file" && os_ver=8s
|
||||||
grep -qi rocky "$rh_file" && os_type=rocky
|
elif grep -qs "release 9" "$rh_file"; then
|
||||||
grep -qi alma "$rh_file" && os_type=alma
|
os_ver=9
|
||||||
|
grep -qi stream "$rh_file" && os_ver=9s
|
||||||
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
os_type=amzn
|
os_type=amzn
|
||||||
os_ver=2
|
os_ver=2
|
||||||
@ -151,7 +154,7 @@ confirm_or_abort() {
|
|||||||
show_header() {
|
show_header() {
|
||||||
cat <<'EOF'
|
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
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,22 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
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
|
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
|
||||||
exiterr "CentOS Linux 8 is EOL and not supported."
|
exiterr "CentOS Linux 8 is EOL and not supported."
|
||||||
fi
|
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
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
os_type=amzn
|
os_type=amzn
|
||||||
os_ver=2
|
os_ver=2
|
||||||
|
@ -40,7 +40,8 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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 rocky "$rh_file" && os_type=rocky
|
||||||
grep -qi alma "$rh_file" && os_type=alma
|
grep -qi alma "$rh_file" && os_type=alma
|
||||||
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
@ -272,8 +273,12 @@ update_iptables_rules() {
|
|||||||
else
|
else
|
||||||
nft_bk=$(find /etc/sysconfig -maxdepth 1 -name 'nftables.conf.old-*-*-*-*_*_*' -print0 \
|
nft_bk=$(find /etc/sysconfig -maxdepth 1 -name 'nftables.conf.old-*-*-*-*_*_*' -print0 \
|
||||||
| xargs -r -0 ls -1 -t | head -1)
|
| 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" ] \
|
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..."
|
bigecho "Restoring nftables rules..."
|
||||||
conf_bk "$IPT_FILE"
|
conf_bk "$IPT_FILE"
|
||||||
/bin/cp -f "$nft_bk" "$IPT_FILE" && /bin/rm -f "$nft_bk"
|
/bin/cp -f "$nft_bk" "$IPT_FILE" && /bin/rm -f "$nft_bk"
|
||||||
|
@ -43,16 +43,19 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
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
|
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
|
||||||
exiterr "CentOS Linux 8 is EOL and not supported."
|
exiterr "CentOS Linux 8 is EOL and not supported."
|
||||||
fi
|
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
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
os_type=amzn
|
os_type=amzn
|
||||||
os_ver=2
|
os_ver=2
|
||||||
|
@ -46,16 +46,19 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
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
|
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
|
||||||
exiterr "CentOS Linux 8 is EOL and not supported."
|
exiterr "CentOS Linux 8 is EOL and not supported."
|
||||||
fi
|
fi
|
||||||
|
elif grep -qs "release 9" "$rh_file"; then
|
||||||
|
os_ver=9
|
||||||
|
grep -qi stream "$rh_file" && os_ver=9s
|
||||||
else
|
else
|
||||||
cat 1>&2 <<'EOF'
|
cat 1>&2 <<'EOF'
|
||||||
Error: This script only supports one of the following OS:
|
Error: This script only supports one of the following OS:
|
||||||
|
10
vpnsetup.sh
10
vpnsetup.sh
@ -75,16 +75,22 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
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
|
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
|
||||||
exiterr "CentOS Linux 8 is EOL and not supported."
|
exiterr "CentOS Linux 8 is EOL and not supported."
|
||||||
fi
|
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
|
elif grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
os_type=amzn
|
os_type=amzn
|
||||||
os_ver=2
|
os_ver=2
|
||||||
|
@ -80,16 +80,22 @@ check_os() {
|
|||||||
os_type=rhel
|
os_type=rhel
|
||||||
fi
|
fi
|
||||||
[ -f /etc/oracle-release ] && os_type=ol
|
[ -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
|
if grep -qs "release 7" "$rh_file"; then
|
||||||
os_ver=7
|
os_ver=7
|
||||||
elif grep -qs "release 8" "$rh_file"; then
|
elif grep -qs "release 8" "$rh_file"; then
|
||||||
os_ver=8
|
os_ver=8
|
||||||
grep -qi stream "$rh_file" && os_ver=8s
|
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
|
if [ "$os_type" = "centos" ] && [ "$os_ver" = "8" ]; then
|
||||||
exiterr "CentOS Linux 8 is EOL and not supported."
|
exiterr "CentOS Linux 8 is EOL and not supported."
|
||||||
fi
|
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
|
else
|
||||||
cat 1>&2 <<'EOF'
|
cat 1>&2 <<'EOF'
|
||||||
Error: This script only supports one of the following OS:
|
Error: This script only supports one of the following OS:
|
||||||
@ -218,12 +224,15 @@ install_vpn_pkgs_1() {
|
|||||||
rp1="$erp=epel"
|
rp1="$erp=epel"
|
||||||
rp2="$erp=*server-*optional*"
|
rp2="$erp=*server-*optional*"
|
||||||
rp3="$erp=*releases-optional*"
|
rp3="$erp=*releases-optional*"
|
||||||
if [ "$os_type" = "ol" ] && [ "$os_ver" = "8" ]; then
|
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"
|
rp1="$erp=ol8_developer_EPEL"
|
||||||
fi
|
else
|
||||||
if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then
|
|
||||||
rp3="$erp=ol7_optional_latest"
|
rp3="$erp=ol7_optional_latest"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
yum -y -q install nss-devel nspr-devel pkgconfig pam-devel \
|
yum -y -q install nss-devel nspr-devel pkgconfig pam-devel \
|
||||||
@ -255,7 +264,8 @@ install_vpn_pkgs_3() {
|
|||||||
set -x
|
set -x
|
||||||
yum -y -q install $p1 $p2 >/dev/null
|
yum -y -q install $p1 $p2 >/dev/null
|
||||||
) || exiterr2
|
) || exiterr2
|
||||||
if systemctl is-active --quiet firewalld \
|
if [ "$os_ver" = "9" ] || [ "$os_ver" = "9s" ] \
|
||||||
|
|| systemctl is-active --quiet firewalld \
|
||||||
|| systemctl is-active --quiet nftables \
|
|| systemctl is-active --quiet nftables \
|
||||||
|| grep -qs "hwdsl2 VPN script" /etc/sysconfig/nftables.conf; then
|
|| grep -qs "hwdsl2 VPN script" /etc/sysconfig/nftables.conf; then
|
||||||
use_nft=1
|
use_nft=1
|
||||||
|
Loading…
Reference in New Issue
Block a user