1
0
mirror of synced 2024-11-24 05:46:09 +03:00

Compare commits

...

3 Commits

Author SHA1 Message Date
hwdsl2
6ca52bf0e0 Update docs 2022-07-30 03:00:14 -05:00
hwdsl2
10d54262fb Add CentOS 9
- Add support for version 9 of CentOS Stream, RHEL, Rocky Linux
  and AlmaLinux.
2022-07-30 02:59:49 -05:00
hwdsl2
066cb14e14 Cleanup 2022-07-30 00:50:40 -05:00
10 changed files with 67 additions and 51 deletions

View File

@ -72,10 +72,10 @@ https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/vpnsetup.sh
- Ubuntu 22.04, 20.04 或者 18.04 - Ubuntu 22.04, 20.04 或者 18.04
- Debian 11 或者 10 - Debian 11 或者 10
- CentOS 7 或者 CentOS Stream 8 - CentOS 7 或者 CentOS Stream 9/8
- Rocky Linux 或者 AlmaLinux 8 - Rocky Linux 或者 AlmaLinux 9/8
- Oracle Linux 8 或者 7 - Oracle Linux 8 或者 7
- Red Hat Enterprise Linux (RHEL) 8 或者 7 - Red Hat Enterprise Linux (RHEL) 9, 8 或者 7
- Amazon Linux 2 - Amazon Linux 2
- Alpine Linux 3.16 或者 3.15 - Alpine Linux 3.16 或者 3.15

View File

@ -72,10 +72,10 @@ A cloud server, virtual private server (VPS) or dedicated server, freshly instal
- Ubuntu 22.04, 20.04 or 18.04 - Ubuntu 22.04, 20.04 or 18.04
- Debian 11 or 10 - Debian 11 or 10
- CentOS 7 or CentOS Stream 8 - CentOS 7 or CentOS Stream 9/8
- Rocky Linux or AlmaLinux 8 - Rocky Linux or AlmaLinux 9/8
- Oracle Linux 8 or 7 - Oracle Linux 8 or 7
- Red Hat Enterprise Linux (RHEL) 8 or 7 - Red Hat Enterprise Linux (RHEL) 9, 8 or 7
- Amazon Linux 2 - Amazon Linux 2
- Alpine Linux 3.16 or 3.15 - Alpine Linux 3.16 or 3.15

View File

@ -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
} }

View File

@ -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
} }

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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:
@ -163,14 +166,9 @@ install_pkgs_2() {
erp="--enablerepo" erp="--enablerepo"
rp1="$erp=*server-*optional*" rp1="$erp=*server-*optional*"
rp2="$erp=*releases-optional*" rp2="$erp=*releases-optional*"
rp3="$erp=[Pp]ower[Tt]ools"
if [ "$os_type" = "ol" ] && [ "$os_ver" = "8" ]; then
rp3="$erp=ol8_codeready_builder"
fi
if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then
rp2="$erp=ol7_optional_latest" rp2="$erp=ol7_optional_latest"
fi fi
[ "$os_type" = "rhel" ] && rp3="$erp=codeready-builder-for-rhel-8-*"
if [ "$os_ver" = "7" ]; then if [ "$os_ver" = "7" ]; then
( (
set -x set -x
@ -179,7 +177,7 @@ install_pkgs_2() {
else else
( (
set -x set -x
yum "$rp3" -y -q install systemd-devel libevent-devel fipscheck-devel >/dev/null yum -y -q install systemd-devel libevent-devel >/dev/null
) || exiterr2 ) || exiterr2
fi fi
} }

View File

@ -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

View File

@ -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,15 +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*"
rp4="$erp=[Pp]ower[Tt]ools" if [ "$os_type" = "ol" ]; then
if [ "$os_type" = "ol" ] && [ "$os_ver" = "8" ]; 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"
rp4="$erp=ol8_codeready_builder" else
fi
if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then
rp3="$erp=ol7_optional_latest" rp3="$erp=ol7_optional_latest"
fi fi
[ "$os_type" = "rhel" ] && rp4="$erp=codeready-builder-for-rhel-8-*" 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 \
@ -256,9 +262,10 @@ install_vpn_pkgs_3() {
else else
( (
set -x set -x
yum "$rp4" -y -q install $p1 $p2 $p3 >/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