1
0
mirror of synced 2024-11-25 22:36:04 +03:00

Improve VPN setup

- Add fallback URLs for improved reliability
This commit is contained in:
hwdsl2 2022-04-11 22:36:43 -05:00
parent dcef96623c
commit a1ab13d9a9
7 changed files with 73 additions and 44 deletions

View File

@ -253,7 +253,8 @@ install_pkgs() {
} }
get_setup_url() { 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" sh_file="vpnsetup_ubuntu.sh"
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \ if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then || [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
@ -263,14 +264,16 @@ get_setup_url() {
elif [ "$os_type" = "alpine" ]; then elif [ "$os_type" = "alpine" ]; then
sh_file="vpnsetup_alpine.sh" sh_file="vpnsetup_alpine.sh"
fi fi
setup_url="$base_url/$sh_file" setup_url1="$base_url1/$sh_file"
setup_url2="$base_url2/$sh_file"
} }
run_setup() { run_setup() {
status=0 status=0
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then 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" \ if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url1" \
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then || 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_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_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \ VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \

View File

@ -134,7 +134,8 @@ install_pkgs() {
} }
get_setup_url() { 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" sh_file="vpnupgrade_ubuntu.sh"
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \ if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then || [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
@ -144,14 +145,16 @@ get_setup_url() {
elif [ "$os_type" = "alpine" ]; then elif [ "$os_type" = "alpine" ]; then
sh_file="vpnupgrade_alpine.sh" sh_file="vpnupgrade_alpine.sh"
fi fi
setup_url="$base_url/$sh_file" setup_url1="$base_url1/$sh_file"
setup_url2="$base_url2/$sh_file"
} }
run_setup() { run_setup() {
status=0 status=0
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then 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" \ if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpnup.sh" "$setup_url1" \
|| curl -fsL "$setup_url" -o "$tmpdir/vpnup.sh" 2>/dev/null ); then || 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 VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$tmpdir/vpnup.sh" || status=1
else else
status=1 status=1

View File

@ -253,7 +253,8 @@ install_pkgs() {
} }
get_setup_url() { 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" sh_file="vpnsetup_ubuntu.sh"
if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \ if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] \
|| [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then || [ "$os_type" = "alma" ] || [ "$os_type" = "ol" ]; then
@ -263,14 +264,16 @@ get_setup_url() {
elif [ "$os_type" = "alpine" ]; then elif [ "$os_type" = "alpine" ]; then
sh_file="vpnsetup_alpine.sh" sh_file="vpnsetup_alpine.sh"
fi fi
setup_url="$base_url/$sh_file" setup_url1="$base_url1/$sh_file"
setup_url2="$base_url2/$sh_file"
} }
run_setup() { run_setup() {
status=0 status=0
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then 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" \ if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url1" \
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then || 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_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_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \ VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \

View File

@ -193,18 +193,23 @@ install_fail2ban() {
get_helper_scripts() { get_helper_scripts() {
bigecho "Downloading helper scripts..." bigecho "Downloading helper scripts..."
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras" base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
ikev2_url="$base_url/ikev2setup.sh" base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
add_url="$base_url/add_vpn_user.sh" ikev2_url1="$base_url1/ikev2setup.sh"
del_url="$base_url/del_vpn_user.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 cd /opt/src || exit 1
printf '%s' "+ " printf '%s' "+ "
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url" [ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url" [ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url" [ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
printf '%s' "$sc " 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 [ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done done
echo echo

View File

@ -193,18 +193,23 @@ install_fail2ban() {
get_helper_scripts() { get_helper_scripts() {
bigecho "Downloading helper scripts..." bigecho "Downloading helper scripts..."
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras" base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
ikev2_url="$base_url/ikev2setup.sh" base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
add_url="$base_url/add_vpn_user.sh" ikev2_url1="$base_url1/ikev2setup.sh"
del_url="$base_url/del_vpn_user.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 cd /opt/src || exit 1
printf '%s' "+ " printf '%s' "+ "
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url" [ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url" [ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url" [ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
printf '%s' "$sc " 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 [ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done done
echo echo

View File

@ -264,18 +264,23 @@ install_fail2ban() {
get_helper_scripts() { get_helper_scripts() {
bigecho "Downloading helper scripts..." bigecho "Downloading helper scripts..."
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras" base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
ikev2_url="$base_url/ikev2setup.sh" base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
add_url="$base_url/add_vpn_user.sh" ikev2_url1="$base_url1/ikev2setup.sh"
del_url="$base_url/del_vpn_user.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 cd /opt/src || exit 1
printf '%s' "+ " printf '%s' "+ "
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url" [ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url" [ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url" [ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
printf '%s' "$sc " 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 [ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done done
echo echo

View File

@ -233,18 +233,23 @@ install_fail2ban() {
get_helper_scripts() { get_helper_scripts() {
bigecho "Downloading helper scripts..." bigecho "Downloading helper scripts..."
base_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras" base_url1="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras"
ikev2_url="$base_url/ikev2setup.sh" base_url2="https://gitlab.com/hwdsl2/setup-ipsec-vpn/-/raw/master/extras"
add_url="$base_url/add_vpn_user.sh" ikev2_url1="$base_url1/ikev2setup.sh"
del_url="$base_url/del_vpn_user.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 cd /opt/src || exit 1
printf '%s' "+ " printf '%s' "+ "
for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do for sc in ikev2.sh addvpnuser.sh delvpnuser.sh; do
[ "$sc" = "ikev2.sh" ] && dl_url="$ikev2_url" [ "$sc" = "ikev2.sh" ] && dl_url1="$ikev2_url1" && dl_url2="$ikev2_url2"
[ "$sc" = "addvpnuser.sh" ] && dl_url="$add_url" [ "$sc" = "addvpnuser.sh" ] && dl_url1="$add_url1" && dl_url2="$add_url2"
[ "$sc" = "delvpnuser.sh" ] && dl_url="$del_url" [ "$sc" = "delvpnuser.sh" ] && dl_url1="$del_url1" && dl_url2="$del_url2"
printf '%s' "$sc " 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 [ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done done
echo echo