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:
parent
1972501725
commit
2e7b3f1bf4
@ -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,30 +258,33 @@ 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"
|
||||||
|
echo
|
||||||
|
printf "Do you want to continue anyway? [y/N] "
|
||||||
|
read -r response
|
||||||
|
case $response in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
echo
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Abort. No changes were made."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
printf "Do you want to continue anyway? [y/N] "
|
|
||||||
read -r response
|
|
||||||
case $response in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
echo
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Abort. No changes were made."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user