Improve VPN setup
- Add fallback URLs for improved reliability
This commit is contained in:
parent
dcef96623c
commit
a1ab13d9a9
@ -253,7 +253,8 @@ install_pkgs() {
|
||||
}
|
||||
|
||||
get_setup_url() {
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master"
|
||||
sh_file="vpnsetup_ubuntu.sh"
|
||||
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|
||||
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
|
||||
@ -263,14 +264,16 @@ get_setup_url() {
|
||||
elif [ "$os_type" = "alpine" ]; then
|
||||
sh_file="vpnsetup_alpine.sh"
|
||||
fi
|
||||
setup_url="$base_url/$sh_file"
|
||||
setup_url1="$base_url1/$sh_file"
|
||||
setup_url2="$base_url2/$sh_file"
|
||||
}
|
||||
|
||||
run_setup() {
|
||||
status=0
|
||||
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url" \
|
||||
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url2" \
|
||||
|| curl -fsL "$setup_url1" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||
VPN_IPSEC_PSK="$VPN_IPSEC_PSK" VPN_USER="$VPN_USER" VPN_PASSWORD="$VPN_PASSWORD" \
|
||||
VPN_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
|
||||
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \
|
||||
|
@ -134,7 +134,8 @@ install_pkgs() {
|
||||
}
|
||||
|
||||
get_setup_url() {
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
|
||||
sh_file="vpnupgrade_ubuntu.sh"
|
||||
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|
||||
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
|
||||
@ -144,14 +145,16 @@ get_setup_url() {
|
||||
elif [ "$os_type" = "alpine" ]; then
|
||||
sh_file="vpnupgrade_alpine.sh"
|
||||
fi
|
||||
setup_url="$base_url/$sh_file"
|
||||
setup_url1="$base_url1/$sh_file"
|
||||
setup_url2="$base_url2/$sh_file"
|
||||
}
|
||||
|
||||
run_setup() {
|
||||
status=0
|
||||
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpnup.sh" "$setup_url" \
|
||||
|| curl -fsL "$setup_url" -o "$tmpdir/vpnup.sh" 2>/dev/null ); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpnup.sh" "$setup_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$tmpdir/vpnup.sh" "$setup_url2" \
|
||||
|| curl -fsL "$setup_url1" -o "$tmpdir/vpnup.sh" 2>/dev/null ); then
|
||||
VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$tmpdir/vpnup.sh" || status=1
|
||||
else
|
||||
status=1
|
||||
|
11
vpnsetup.sh
11
vpnsetup.sh
@ -253,7 +253,8 @@ install_pkgs() {
|
||||
}
|
||||
|
||||
get_setup_url() {
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master"
|
||||
sh_file="vpnsetup_ubuntu.sh"
|
||||
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|
||||
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
|
||||
@ -263,14 +264,16 @@ get_setup_url() {
|
||||
elif [ "$os_type" = "alpine" ]; then
|
||||
sh_file="vpnsetup_alpine.sh"
|
||||
fi
|
||||
setup_url="$base_url/$sh_file"
|
||||
setup_url1="$base_url1/$sh_file"
|
||||
setup_url2="$base_url2/$sh_file"
|
||||
}
|
||||
|
||||
run_setup() {
|
||||
status=0
|
||||
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url" \
|
||||
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url2" \
|
||||
|| curl -fsL "$setup_url1" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||
VPN_IPSEC_PSK="$VPN_IPSEC_PSK" VPN_USER="$VPN_USER" VPN_PASSWORD="$VPN_PASSWORD" \
|
||||
VPN_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
|
||||
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \
|
||||
|
@ -193,18 +193,23 @@ install_fail2ban() {
|
||||
|
||||
get_helper_scripts() {
|
||||
bigecho "Downloading helper scripts..."
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
ikev2_url="$base_url/ikev2setup.sh"
|
||||
add_url="$base_url/add_vpn_user.sh"
|
||||
del_url="$base_url/del_vpn_user.sh"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
|
||||
ikev2_url1="$base_url1/ikev2setup.sh"
|
||||
ikev2_url2="$base_url2/ikev2setup.sh"
|
||||
add_url1="$base_url1/add_vpn_user.sh"
|
||||
add_url2="$base_url2/add_vpn_user.sh"
|
||||
del_url1="$base_url1/del_vpn_user.sh"
|
||||
del_url2="$base_url2/del_vpn_user.sh"
|
||||
cd /opt/src || exit 1
|
||||
printf '%s' "+ "
|
||||
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url"
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
|
||||
printf '%s' "$sc "
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url" || /bin/rm -f "$sc"
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$sc" "$dl_url2" || /bin/rm -f "$sc"
|
||||
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
|
||||
done
|
||||
echo
|
||||
|
@ -193,18 +193,23 @@ install_fail2ban() {
|
||||
|
||||
get_helper_scripts() {
|
||||
bigecho "Downloading helper scripts..."
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
ikev2_url="$base_url/ikev2setup.sh"
|
||||
add_url="$base_url/add_vpn_user.sh"
|
||||
del_url="$base_url/del_vpn_user.sh"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
|
||||
ikev2_url1="$base_url1/ikev2setup.sh"
|
||||
ikev2_url2="$base_url2/ikev2setup.sh"
|
||||
add_url1="$base_url1/add_vpn_user.sh"
|
||||
add_url2="$base_url2/add_vpn_user.sh"
|
||||
del_url1="$base_url1/del_vpn_user.sh"
|
||||
del_url2="$base_url2/del_vpn_user.sh"
|
||||
cd /opt/src || exit 1
|
||||
printf '%s' "+ "
|
||||
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url"
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
|
||||
printf '%s' "$sc "
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url" || /bin/rm -f "$sc"
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$sc" "$dl_url2" || /bin/rm -f "$sc"
|
||||
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
|
||||
done
|
||||
echo
|
||||
|
@ -264,18 +264,23 @@ install_fail2ban() {
|
||||
|
||||
get_helper_scripts() {
|
||||
bigecho "Downloading helper scripts..."
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
ikev2_url="$base_url/ikev2setup.sh"
|
||||
add_url="$base_url/add_vpn_user.sh"
|
||||
del_url="$base_url/del_vpn_user.sh"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
|
||||
ikev2_url1="$base_url1/ikev2setup.sh"
|
||||
ikev2_url2="$base_url2/ikev2setup.sh"
|
||||
add_url1="$base_url1/add_vpn_user.sh"
|
||||
add_url2="$base_url2/add_vpn_user.sh"
|
||||
del_url1="$base_url1/del_vpn_user.sh"
|
||||
del_url2="$base_url2/del_vpn_user.sh"
|
||||
cd /opt/src || exit 1
|
||||
printf '%s' "+ "
|
||||
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url"
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
|
||||
printf '%s' "$sc "
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url" || /bin/rm -f "$sc"
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$sc" "$dl_url2" || /bin/rm -f "$sc"
|
||||
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
|
||||
done
|
||||
echo
|
||||
|
@ -233,18 +233,23 @@ install_fail2ban() {
|
||||
|
||||
get_helper_scripts() {
|
||||
bigecho "Downloading helper scripts..."
|
||||
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
ikev2_url="$base_url/ikev2setup.sh"
|
||||
add_url="$base_url/add_vpn_user.sh"
|
||||
del_url="$base_url/del_vpn_user.sh"
|
||||
base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
|
||||
base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
|
||||
ikev2_url1="$base_url1/ikev2setup.sh"
|
||||
ikev2_url2="$base_url2/ikev2setup.sh"
|
||||
add_url1="$base_url1/add_vpn_user.sh"
|
||||
add_url2="$base_url2/add_vpn_user.sh"
|
||||
del_url1="$base_url1/del_vpn_user.sh"
|
||||
del_url2="$base_url2/del_vpn_user.sh"
|
||||
cd /opt/src || exit 1
|
||||
printf '%s' "+ "
|
||||
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url"
|
||||
[ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
|
||||
[ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
|
||||
[ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
|
||||
printf '%s' "$sc "
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url" || /bin/rm -f "$sc"
|
||||
wget -t 3 -T 30 -q -O "$sc" "$dl_url1" \
|
||||
|| wget -t 3 -T 30 -q -O "$sc" "$dl_url2" || /bin/rm -f "$sc"
|
||||
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
|
||||
done
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user