1
0
mirror of synced 2024-11-22 04:56:03 +03:00
This commit is contained in:
hwdsl2 2022-03-07 21:29:13 -06:00
parent 17c429b2fb
commit e5703d8aaa
13 changed files with 25 additions and 13 deletions

View File

@ -90,7 +90,7 @@ EOF
check_libreswan() {
ipsec_ver=$(ipsec --version 2>/dev/null)
if ( ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf && ! grep -qs "hwdsl2" /opt/src/run.sh ) \
|| ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|| ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script can only be used with an IPsec server created using:
https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -49,7 +49,7 @@ check_libreswan() {
swan_ver=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf \
|| ! grep -qs "config setup" /etc/ipsec.conf \
|| ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|| ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: Your must first set up the IPsec VPN server before selecting IKEv2-only mode.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -101,7 +101,7 @@ EOF
check_libreswan() {
ipsec_ver=$(ipsec --version 2>/dev/null)
if ( ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf && ! grep -qs "hwdsl2" /opt/src/run.sh ) \
|| ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|| ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: Your must first set up the IPsec VPN server before setting up IKEv2.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -71,7 +71,7 @@ EOF
check_libreswan() {
ipsec_ver=$(ipsec --version 2>/dev/null)
if ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf \
|| ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|| ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
exiterr "Cannot remove IPsec VPN because it has not been set up on this server."
fi
}

View File

@ -93,7 +93,7 @@ EOF
check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
if ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script requires Libreswan already installed.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -59,7 +59,7 @@ check_os() {
check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
if ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script requires Libreswan already installed.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -42,7 +42,7 @@ check_os() {
check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
if ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script requires Libreswan already installed.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -60,7 +60,7 @@ check_os() {
check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
if ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script requires Libreswan already installed.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -65,7 +65,7 @@ check_os() {
check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
if ! printf '%s' "$ipsec_ver" | grep -qi 'libreswan'; then
cat 1>&2 <<'EOF'
Error: This script requires Libreswan already installed.
See: https://github.com/hwdsl2/setup-ipsec-vpn

View File

@ -202,11 +202,14 @@ get_swan_ver() {
}
check_libreswan() {
ipsec_bin="/usr/local/sbin/ipsec"
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if [ -n "$swan_ver_old" ] && [ "$(find /usr/local/sbin/ipsec -mmin -10080)" ]; then
if [ -n "$swan_ver_old" ] && printf '%s' "$ipsec_ver" | grep -qi 'libreswan' \
&& [ "$(find "$ipsec_bin" -mmin -10080)" ]; then
return 0
fi
[ -s "$ipsec_bin" ] && touch "$ipsec_bin"
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ]
}

View File

@ -202,11 +202,14 @@ get_swan_ver() {
}
check_libreswan() {
ipsec_bin="/usr/local/sbin/ipsec"
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if [ -n "$swan_ver_old" ] && [ "$(find /usr/local/sbin/ipsec -mmin -10080)" ]; then
if [ -n "$swan_ver_old" ] && printf '%s' "$ipsec_ver" | grep -qi 'libreswan' \
&& [ "$(find "$ipsec_bin" -mmin -10080)" ]; then
return 0
fi
[ -s "$ipsec_bin" ] && touch "$ipsec_bin"
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ]
}

View File

@ -259,11 +259,14 @@ get_swan_ver() {
}
check_libreswan() {
ipsec_bin="/usr/local/sbin/ipsec"
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if [ -n "$swan_ver_old" ] && [ "$(find /usr/local/sbin/ipsec -mmin -10080)" ]; then
if [ -n "$swan_ver_old" ] && printf '%s' "$ipsec_ver" | grep -qi 'libreswan' \
&& [ "$(find "$ipsec_bin" -mmin -10080)" ]; then
return 0
fi
[ -s "$ipsec_bin" ] && touch "$ipsec_bin"
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ]
}

View File

@ -242,11 +242,14 @@ get_swan_ver() {
}
check_libreswan() {
ipsec_bin="/usr/local/sbin/ipsec"
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
if [ -n "$swan_ver_old" ] && [ "$(find /usr/local/sbin/ipsec -mmin -10080)" ]; then
if [ -n "$swan_ver_old" ] && printf '%s' "$ipsec_ver" | grep -qi 'libreswan' \
&& [ "$(find "$ipsec_bin" -mmin -10080)" ]; then
return 0
fi
[ -s "$ipsec_bin" ] && touch "$ipsec_bin"
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ]
}