From 46a83e4f9f80b60f36e1e26e58667932cae6f66c Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Tue, 8 Mar 2022 21:17:16 -0600 Subject: [PATCH] Cleanup --- vpnsetup_alpine.sh | 6 ++++-- vpnsetup_amzn.sh | 6 ++++-- vpnsetup_centos.sh | 6 ++++-- vpnsetup_ubuntu.sh | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/vpnsetup_alpine.sh b/vpnsetup_alpine.sh index 26472d4..910102d 100755 --- a/vpnsetup_alpine.sh +++ b/vpnsetup_alpine.sh @@ -202,15 +202,17 @@ 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\).*//') + ipsec_bin="/usr/local/sbin/ipsec" 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 + if [ -s "$ipsec_bin" ] && [ "$swan_ver_old" = "$SWAN_VER" ]; then + touch "$ipsec_bin" + fi [ "$swan_ver_old" = "$SWAN_VER" ] } diff --git a/vpnsetup_amzn.sh b/vpnsetup_amzn.sh index 8e5543b..7ec74e7 100755 --- a/vpnsetup_amzn.sh +++ b/vpnsetup_amzn.sh @@ -202,15 +202,17 @@ 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\).*//') + ipsec_bin="/usr/local/sbin/ipsec" 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 + if [ -s "$ipsec_bin" ] && [ "$swan_ver_old" = "$SWAN_VER" ]; then + touch "$ipsec_bin" + fi [ "$swan_ver_old" = "$SWAN_VER" ] } diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index 4dc4ef9..e27838d 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -259,15 +259,17 @@ 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\).*//') + ipsec_bin="/usr/local/sbin/ipsec" 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 + if [ -s "$ipsec_bin" ] && [ "$swan_ver_old" = "$SWAN_VER" ]; then + touch "$ipsec_bin" + fi [ "$swan_ver_old" = "$SWAN_VER" ] } diff --git a/vpnsetup_ubuntu.sh b/vpnsetup_ubuntu.sh index 0204572..7eac4b9 100755 --- a/vpnsetup_ubuntu.sh +++ b/vpnsetup_ubuntu.sh @@ -242,15 +242,17 @@ 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\).*//') + ipsec_bin="/usr/local/sbin/ipsec" 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 + if [ -s "$ipsec_bin" ] && [ "$swan_ver_old" = "$SWAN_VER" ]; then + touch "$ipsec_bin" + fi [ "$swan_ver_old" = "$SWAN_VER" ] }