1
0
mirror of synced 2024-11-26 06:46:06 +03:00

Update IKEv2 script

- Make it easier for users to update Libreswan when the script is not
  running in auto mode
This commit is contained in:
hwdsl2 2021-02-26 00:42:02 -06:00
parent 1972501725
commit 2e7b3f1bf4

View File

@ -227,6 +227,30 @@ check_swan_ver() {
swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url") swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url")
} }
run_swan_update() {
update_url=vpnupgrade
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ]; then
update_url=vpnupgrade-centos
elif [ "$os_type" = "amzn" ]; then
update_url=vpnupgrade-amzn
fi
TMPDIR=$(mktemp -d /tmp/vpnupg.XXX 2>/dev/null)
if [ -d "$TMPDIR" ]; then
set -x
if wget -t 3 -T 30 -q -O "$TMPDIR/vpnupg.sh" "https://git.io/$update_url"; then
/bin/sh "$TMPDIR/vpnupg.sh"
fi
{ set +x; } 2>&-
[ ! -s "$TMPDIR/vpnupg.sh" ] && echo "Error: Could not download update script." >&2
/bin/rm -f "$TMPDIR/vpnupg.sh"
/bin/rmdir "$TMPDIR"
else
echo "Error: Could not create temporary directory." >&2
fi
read -n 1 -s -r -p "Press any key to continue IKEv2 setup..."
echo
}
select_swan_update() { select_swan_update() {
if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])$' \ if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])$' \
&& [ "$swan_ver" != "$swan_ver_latest" ] \ && [ "$swan_ver" != "$swan_ver_latest" ] \
@ -234,18 +258,20 @@ select_swan_update() {
echo "Note: A newer version of Libreswan ($swan_ver_latest) is available." echo "Note: A newer version of Libreswan ($swan_ver_latest) is available."
echo " It is recommended to update Libreswan before setting up IKEv2." echo " It is recommended to update Libreswan before setting up IKEv2."
if [ "$in_container" = "0" ]; then if [ "$in_container" = "0" ]; then
echo " To update, exit this script and run:" echo
update_url=vpnupgrade printf "Do you want to update Libreswan? [Y/n] "
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ]; then read -r response
update_url=vpnupgrade-centos case $response in
elif [ "$os_type" = "amzn" ]; then [yY][eE][sS]|[yY]|'')
update_url=vpnupgrade-amzn echo
fi run_swan_update
echo " wget https://git.io/$update_url -O vpnupgrade.sh" ;;
echo " sudo sh vpnupgrade.sh" *)
echo
;;
esac
else else
echo " To update this Docker image, see: https://git.io/updatedockervpn" echo " To update this Docker image, see: https://git.io/updatedockervpn"
fi
echo echo
printf "Do you want to continue anyway? [y/N] " printf "Do you want to continue anyway? [y/N] "
read -r response read -r response
@ -259,6 +285,7 @@ select_swan_update() {
;; ;;
esac esac
fi fi
fi
} }
show_welcome_message() { show_welcome_message() {