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

Compare commits

..

No commits in common. "6ca52bf0e04e7cef0537470dbf34b0eb216b2ecb" and "a0d0c42651e4d0a5d1425adc922ceda45d662064" have entirely different histories.

10 changed files with 51 additions and 67 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 9/8 - CentOS 7 或者 CentOS Stream 8
- Rocky Linux 或者 AlmaLinux 9/8 - Rocky Linux 或者 AlmaLinux 8
- Oracle Linux 8 或者 7 - Oracle Linux 8 或者 7
- Red Hat Enterprise Linux (RHEL) 9, 8 或者 7 - Red Hat Enterprise Linux (RHEL) 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 9/8 - CentOS 7 or CentOS Stream 8
- Rocky Linux or AlmaLinux 9/8 - Rocky Linux or AlmaLinux 8
- Oracle Linux 8 or 7 - Oracle Linux 8 or 7
- Red Hat Enterprise Linux (RHEL) 9, 8 or 7 - Red Hat Enterprise Linux (RHEL) 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,12 +42,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
if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file" \ if grep -qs "release 7" "$rh_file"; then
|| grep -qs "release 9" "$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 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")
@ -73,6 +77,14 @@ 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,16 +53,13 @@ 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
elif grep -qs "release 9" "$rh_file"; then grep -qi rocky "$rh_file" && os_type=rocky
os_ver=9 grep -qi alma "$rh_file" && os_type=alma
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
@ -154,7 +151,7 @@ confirm_or_abort() {
show_header() { show_header() {
cat <<'EOF' cat <<'EOF'
IKEv2 Script Copyright (c) 2020-2022 Lin Song 31 Jul 2022 IKEv2 Script Copyright (c) 2020-2022 Lin Song 27 Jul 2022
EOF EOF
} }

View File

@ -75,22 +75,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
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,8 +40,7 @@ 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" \ if grep -qs "release 7" "$rh_file" || grep -qs "release 8" "$rh_file"; then
|| 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
@ -273,12 +272,8 @@ 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)" = "$diff_count" ]; then && [ "$(diff -y --suppress-common-lines "$IPT_FILE" "$nft_bk" | wc -l)" = "24" ]; 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,19 +43,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
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,19 +46,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
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:
@ -166,9 +163,14 @@ 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
@ -177,7 +179,7 @@ install_pkgs_2() {
else else
( (
set -x set -x
yum -y -q install systemd-devel libevent-devel >/dev/null yum "$rp3" -y -q install systemd-devel libevent-devel fipscheck-devel >/dev/null
) || exiterr2 ) || exiterr2
fi fi
} }

View File

@ -75,22 +75,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
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,22 +80,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
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:
@ -224,15 +218,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" ]; then rp4="$erp=[Pp]ower[Tt]ools"
if [ "$os_ver" = "9" ]; then if [ "$os_type" = "ol" ] && [ "$os_ver" = "8" ]; then
rp1="$erp=ol9_developer_EPEL"
elif [ "$os_ver" = "8" ]; then
rp1="$erp=ol8_developer_EPEL" rp1="$erp=ol8_developer_EPEL"
else rp4="$erp=ol8_codeready_builder"
fi
if [ "$os_type" = "ol" ] && [ "$os_ver" = "7" ]; then
rp3="$erp=ol7_optional_latest" rp3="$erp=ol7_optional_latest"
fi fi
fi [ "$os_type" = "rhel" ] && rp4="$erp=codeready-builder-for-rhel-8-*"
( (
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 \
@ -262,10 +256,9 @@ install_vpn_pkgs_3() {
else else
( (
set -x set -x
yum -y -q install $p1 $p2 >/dev/null yum "$rp4" -y -q install $p1 $p2 $p3 >/dev/null
) || exiterr2 ) || exiterr2
if [ "$os_ver" = "9" ] || [ "$os_ver" = "9s" ] \ if systemctl is-active --quiet firewalld \
|| 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