Improve upgrade scripts
- Make specifying Libreswan version optional in vpnupgrade.sh. Install the latest supported version by default. - Remove Libreswan version check
This commit is contained in:
parent
5b1377dcf3
commit
c56ebe9cfe
@ -14,8 +14,9 @@
|
|||||||
# Attribution required: please include my name in any derivative and let me
|
# Attribution required: please include my name in any derivative and let me
|
||||||
# know how you have improved it!
|
# know how you have improved it!
|
||||||
|
|
||||||
# Specify which Libreswan version to install. See: https://libreswan.org
|
# (Optional) Specify which Libreswan version to install. See: https://libreswan.org
|
||||||
SWAN_VER=4.6
|
# NOTE: If not specified, the latest supported version will be installed.
|
||||||
|
SWAN_VER=
|
||||||
|
|
||||||
### DO NOT edit below this line ###
|
### DO NOT edit below this line ###
|
||||||
|
|
||||||
@ -91,40 +92,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_libreswan() {
|
check_libreswan() {
|
||||||
if [ "$os_type" != "alpine" ]; then
|
|
||||||
case $SWAN_VER in
|
|
||||||
3.32|4.[1-6])
|
|
||||||
true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
cat 1>&2 <<EOF
|
|
||||||
Error: Libreswan version '$SWAN_VER' is not supported.
|
|
||||||
This script can install one of these versions:
|
|
||||||
3.32, 4.1-4.5 or 4.6
|
|
||||||
EOF
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
case $SWAN_VER in
|
|
||||||
4.[5-6])
|
|
||||||
true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
cat 1>&2 <<EOF
|
|
||||||
Error: Libreswan version '$SWAN_VER' is not supported.
|
|
||||||
This script can install one of these versions:
|
|
||||||
4.5 or 4.6
|
|
||||||
EOF
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SWAN_VER" = "3.32" ] && [ "$os_ver" = "11" ]; then
|
|
||||||
exiterr "Libreswan 3.32 is not supported on Debian 11."
|
|
||||||
fi
|
|
||||||
|
|
||||||
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
|
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 -q "Libreswan"; then
|
||||||
cat 1>&2 <<'EOF'
|
cat 1>&2 <<'EOF'
|
||||||
|
@ -39,7 +39,6 @@ check_vz() {
|
|||||||
|
|
||||||
check_os() {
|
check_os() {
|
||||||
os_type=$(lsb_release -si 2>/dev/null)
|
os_type=$(lsb_release -si 2>/dev/null)
|
||||||
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
|
|
||||||
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
||||||
case $os_type in
|
case $os_type in
|
||||||
[Aa]lpine)
|
[Aa]lpine)
|
||||||
@ -139,9 +138,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_setup() {
|
start_setup() {
|
||||||
# shellcheck disable=SC2154
|
|
||||||
trap 'dlo=$dl;dl=$LINENO' DEBUG 2>/dev/null
|
|
||||||
trap 'finish $? $((dlo+1))' EXIT
|
|
||||||
mkdir -p /opt/src
|
mkdir -p /opt/src
|
||||||
cd /opt/src || exit 1
|
cd /opt/src || exit 1
|
||||||
}
|
}
|
||||||
@ -287,28 +283,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_swan_ver() {
|
|
||||||
swan_ver_cur=4.6
|
|
||||||
swan_ver_url="https://dl.ls20.com/v1/$os_type/$os_ver/swanverupg?arch=$os_arch&ver1=$swan_ver_old&ver2=$SWAN_VER"
|
|
||||||
[ "$1" != "0" ] && swan_ver_url="$swan_ver_url&e=$2"
|
|
||||||
swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url" | head -n 1)
|
|
||||||
if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9]{1,2})(\.([0-9]|[1-9][0-9]{1,2})){1,2}$' \
|
|
||||||
&& [ "$1" = "0" ] && [ "$swan_ver_cur" != "$swan_ver_latest" ] \
|
|
||||||
&& printf '%s\n%s' "$swan_ver_cur" "$swan_ver_latest" | sort -C -V; then
|
|
||||||
cat <<EOF
|
|
||||||
Note: A newer version of Libreswan ($swan_ver_latest) is available.
|
|
||||||
To update, run:
|
|
||||||
wget https://git.io/vpnupgrade -O vpnup.sh && sudo sh vpnup.sh
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
check_swan_ver "$1" "$2"
|
|
||||||
exit "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnupgrade() {
|
vpnupgrade() {
|
||||||
check_root
|
check_root
|
||||||
check_vz
|
check_vz
|
||||||
|
@ -32,7 +32,6 @@ check_root() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_os() {
|
check_os() {
|
||||||
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
|
|
||||||
if ! grep -qs "Amazon Linux release 2" /etc/system-release; then
|
if ! grep -qs "Amazon Linux release 2" /etc/system-release; then
|
||||||
exiterr "This script only supports Amazon Linux 2."
|
exiterr "This script only supports Amazon Linux 2."
|
||||||
fi
|
fi
|
||||||
@ -122,9 +121,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_setup() {
|
start_setup() {
|
||||||
# shellcheck disable=SC2154
|
|
||||||
trap 'dlo=$dl;dl=$LINENO' DEBUG 2>/dev/null
|
|
||||||
trap 'finish $? $((dlo+1))' EXIT
|
|
||||||
mkdir -p /opt/src
|
mkdir -p /opt/src
|
||||||
cd /opt/src || exit 1
|
cd /opt/src || exit 1
|
||||||
}
|
}
|
||||||
@ -275,28 +271,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_swan_ver() {
|
|
||||||
swan_ver_cur=4.6
|
|
||||||
swan_ver_url="https://dl.ls20.com/v1/amzn/2/swanverupg?arch=$os_arch&ver1=$swan_ver_old&ver2=$SWAN_VER"
|
|
||||||
[ "$1" != "0" ] && swan_ver_url="$swan_ver_url&e=$2"
|
|
||||||
swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url" | head -n 1)
|
|
||||||
if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9]{1,2})(\.([0-9]|[1-9][0-9]{1,2})){1,2}$' \
|
|
||||||
&& [ "$1" = "0" ] && [ "$swan_ver_cur" != "$swan_ver_latest" ] \
|
|
||||||
&& printf '%s\n%s' "$swan_ver_cur" "$swan_ver_latest" | sort -C -V; then
|
|
||||||
cat <<EOF
|
|
||||||
Note: A newer version of Libreswan ($swan_ver_latest) is available.
|
|
||||||
To update, run:
|
|
||||||
wget https://git.io/vpnupgrade -O vpnup.sh && sudo sh vpnup.sh
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
check_swan_ver "$1" "$2"
|
|
||||||
exit "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnupgrade() {
|
vpnupgrade() {
|
||||||
check_root
|
check_root
|
||||||
check_os
|
check_os
|
||||||
|
@ -39,7 +39,6 @@ check_vz() {
|
|||||||
|
|
||||||
check_os() {
|
check_os() {
|
||||||
os_type=centos
|
os_type=centos
|
||||||
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
|
|
||||||
rh_file="/etc/redhat-release"
|
rh_file="/etc/redhat-release"
|
||||||
if grep -qs "Red Hat" "$rh_file"; then
|
if grep -qs "Red Hat" "$rh_file"; then
|
||||||
os_type=rhel
|
os_type=rhel
|
||||||
@ -140,9 +139,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_setup() {
|
start_setup() {
|
||||||
# shellcheck disable=SC2154
|
|
||||||
trap 'dlo=$dl;dl=$LINENO' DEBUG 2>/dev/null
|
|
||||||
trap 'finish $? $((dlo+1))' EXIT
|
|
||||||
mkdir -p /opt/src
|
mkdir -p /opt/src
|
||||||
cd /opt/src || exit 1
|
cd /opt/src || exit 1
|
||||||
}
|
}
|
||||||
@ -311,28 +307,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_swan_ver() {
|
|
||||||
swan_ver_cur=4.6
|
|
||||||
swan_ver_url="https://dl.ls20.com/v1/$os_type/$os_ver/swanverupg?arch=$os_arch&ver1=$swan_ver_old&ver2=$SWAN_VER"
|
|
||||||
[ "$1" != "0" ] && swan_ver_url="$swan_ver_url&e=$2"
|
|
||||||
swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url" | head -n 1)
|
|
||||||
if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9]{1,2})(\.([0-9]|[1-9][0-9]{1,2})){1,2}$' \
|
|
||||||
&& [ "$1" = "0" ] && [ "$swan_ver_cur" != "$swan_ver_latest" ] \
|
|
||||||
&& printf '%s\n%s' "$swan_ver_cur" "$swan_ver_latest" | sort -C -V; then
|
|
||||||
cat <<EOF
|
|
||||||
Note: A newer version of Libreswan ($swan_ver_latest) is available.
|
|
||||||
To update, run:
|
|
||||||
wget https://git.io/vpnupgrade -O vpnup.sh && sudo sh vpnup.sh
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
check_swan_ver "$1" "$2"
|
|
||||||
exit "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnupgrade() {
|
vpnupgrade() {
|
||||||
check_root
|
check_root
|
||||||
check_vz
|
check_vz
|
||||||
|
@ -39,7 +39,6 @@ check_vz() {
|
|||||||
|
|
||||||
check_os() {
|
check_os() {
|
||||||
os_type=$(lsb_release -si 2>/dev/null)
|
os_type=$(lsb_release -si 2>/dev/null)
|
||||||
os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-')
|
|
||||||
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
[ -z "$os_type" ] && [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID")
|
||||||
case $os_type in
|
case $os_type in
|
||||||
[Uu]buntu)
|
[Uu]buntu)
|
||||||
@ -149,9 +148,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_setup() {
|
start_setup() {
|
||||||
# shellcheck disable=SC2154
|
|
||||||
trap 'dlo=$dl;dl=$LINENO' DEBUG 2>/dev/null
|
|
||||||
trap 'finish $? $((dlo+1))' EXIT
|
|
||||||
mkdir -p /opt/src
|
mkdir -p /opt/src
|
||||||
cd /opt/src || exit 1
|
cd /opt/src || exit 1
|
||||||
}
|
}
|
||||||
@ -318,28 +314,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_swan_ver() {
|
|
||||||
swan_ver_cur=4.6
|
|
||||||
swan_ver_url="https://dl.ls20.com/v1/$os_type/$os_ver/swanverupg?arch=$os_arch&ver1=$swan_ver_old&ver2=$SWAN_VER"
|
|
||||||
[ "$1" != "0" ] && swan_ver_url="$swan_ver_url&e=$2"
|
|
||||||
swan_ver_latest=$(wget -t 3 -T 15 -qO- "$swan_ver_url" | head -n 1)
|
|
||||||
if printf '%s' "$swan_ver_latest" | grep -Eq '^([3-9]|[1-9][0-9]{1,2})(\.([0-9]|[1-9][0-9]{1,2})){1,2}$' \
|
|
||||||
&& [ "$1" = "0" ] && [ "$swan_ver_cur" != "$swan_ver_latest" ] \
|
|
||||||
&& printf '%s\n%s' "$swan_ver_cur" "$swan_ver_latest" | sort -C -V; then
|
|
||||||
cat <<EOF
|
|
||||||
Note: A newer version of Libreswan ($swan_ver_latest) is available.
|
|
||||||
To update, run:
|
|
||||||
wget https://git.io/vpnupgrade -O vpnup.sh && sudo sh vpnup.sh
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
check_swan_ver "$1" "$2"
|
|
||||||
exit "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnupgrade() {
|
vpnupgrade() {
|
||||||
check_root
|
check_root
|
||||||
check_vz
|
check_vz
|
||||||
|
Loading…
Reference in New Issue
Block a user