1
0
mirror of synced 2024-11-28 23:56:04 +03:00

Improve VPN setup

- Skip Libreswan install if it has already been installed recently.
This commit is contained in:
hwdsl2 2022-03-06 22:36:20 -06:00
parent bf4f61474b
commit b6c54c316f
4 changed files with 20 additions and 8 deletions

View File

@ -204,6 +204,10 @@ get_swan_ver() {
check_libreswan() { check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) 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\).*//') 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
return 0
fi
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ] [ "$swan_ver_old" = "$SWAN_VER" ]
} }
@ -221,7 +225,7 @@ get_libreswan() {
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER" /bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
tar xzf "$swan_file" && /bin/rm -f "$swan_file" tar xzf "$swan_file" && /bin/rm -f "$swan_file"
else else
bigecho "Libreswan $SWAN_VER is already installed, skipping..." bigecho "Libreswan $swan_ver_old is already installed, skipping..."
fi fi
} }
@ -552,7 +556,6 @@ vpnsetup() {
install_vpn_pkgs install_vpn_pkgs
install_fail2ban install_fail2ban
get_ikev2_script get_ikev2_script
get_swan_ver
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -204,6 +204,10 @@ get_swan_ver() {
check_libreswan() { check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) 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\).*//') 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
return 0
fi
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ] [ "$swan_ver_old" = "$SWAN_VER" ]
} }
@ -221,7 +225,7 @@ get_libreswan() {
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER" /bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
tar xzf "$swan_file" && /bin/rm -f "$swan_file" tar xzf "$swan_file" && /bin/rm -f "$swan_file"
else else
bigecho "Libreswan $SWAN_VER is already installed, skipping..." bigecho "Libreswan $swan_ver_old is already installed, skipping..."
fi fi
} }
@ -566,7 +570,6 @@ vpnsetup() {
install_vpn_pkgs_2 install_vpn_pkgs_2
install_fail2ban install_fail2ban
get_ikev2_script get_ikev2_script
get_swan_ver
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -261,6 +261,10 @@ get_swan_ver() {
check_libreswan() { check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) 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\).*//') 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
return 0
fi
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ] [ "$swan_ver_old" = "$SWAN_VER" ]
} }
@ -278,7 +282,7 @@ get_libreswan() {
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER" /bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
tar xzf "$swan_file" && /bin/rm -f "$swan_file" tar xzf "$swan_file" && /bin/rm -f "$swan_file"
else else
bigecho "Libreswan $SWAN_VER is already installed, skipping..." bigecho "Libreswan $swan_ver_old is already installed, skipping..."
fi fi
} }
@ -681,7 +685,6 @@ vpnsetup() {
install_vpn_pkgs_3 install_vpn_pkgs_3
install_fail2ban install_fail2ban
get_ikev2_script get_ikev2_script
get_swan_ver
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -244,6 +244,10 @@ get_swan_ver() {
check_libreswan() { check_libreswan() {
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) 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\).*//') 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
return 0
fi
get_swan_ver
[ "$swan_ver_old" = "$SWAN_VER" ] [ "$swan_ver_old" = "$SWAN_VER" ]
} }
@ -261,7 +265,7 @@ get_libreswan() {
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER" /bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
tar xzf "$swan_file" && /bin/rm -f "$swan_file" tar xzf "$swan_file" && /bin/rm -f "$swan_file"
else else
bigecho "Libreswan $SWAN_VER is already installed, skipping..." bigecho "Libreswan $swan_ver_old is already installed, skipping..."
fi fi
} }
@ -669,7 +673,6 @@ vpnsetup() {
install_vpn_pkgs install_vpn_pkgs
install_fail2ban install_fail2ban
get_ikev2_script get_ikev2_script
get_swan_ver
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config