1
0
mirror of synced 2024-11-28 15:56:01 +03:00

Improve VPN setup

- Download the add/delete VPN user helper scripts during setup,
  so users can use them directly without manual download.
This commit is contained in:
hwdsl2 2022-03-13 15:03:28 -05:00
parent d3f9f1944f
commit d182d9651a
4 changed files with 80 additions and 48 deletions

View File

@ -191,6 +191,25 @@ install_fail2ban() {
) || exiterr2 ) || exiterr2
} }
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"
cd /opt/src || exit 1
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"
(
set -x
wget -t 3 -T 30 -q -O "$sc" "$dl_url"
) || /bin/rm -f "$sc"
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done
}
get_swan_ver() { get_swan_ver() {
SWAN_VER=4.6 SWAN_VER=4.6
base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0" base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0"
@ -261,17 +280,6 @@ EOF
fi fi
} }
get_ikev2_script() {
bigecho "Downloading IKEv2 script..."
cd /opt/src || exit 1
ikev2_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras/ikev2setup.sh"
(
set -x
wget -t 3 -T 30 -q -O ikev2.sh "$ikev2_url"
) || /bin/rm -f ikev2.sh
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
}
create_vpn_config() { create_vpn_config() {
bigecho "Creating VPN configuration..." bigecho "Creating VPN configuration..."
@ -555,7 +563,7 @@ vpnsetup() {
detect_ip detect_ip
install_vpn_pkgs install_vpn_pkgs
install_fail2ban install_fail2ban
get_ikev2_script get_helper_scripts
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -191,6 +191,25 @@ install_fail2ban() {
) || exiterr2 ) || exiterr2
} }
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"
cd /opt/src || exit 1
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"
(
set -x
wget -t 3 -T 30 -q -O "$sc" "$dl_url"
) || /bin/rm -f "$sc"
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done
}
get_swan_ver() { get_swan_ver() {
SWAN_VER=4.6 SWAN_VER=4.6
base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0" base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0"
@ -263,17 +282,6 @@ EOF
fi fi
} }
get_ikev2_script() {
bigecho "Downloading IKEv2 script..."
cd /opt/src || exit 1
ikev2_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras/ikev2setup.sh"
(
set -x
wget -t 3 -T 30 -q -O ikev2.sh "$ikev2_url"
) || /bin/rm -f ikev2.sh
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
}
create_vpn_config() { create_vpn_config() {
bigecho "Creating VPN configuration..." bigecho "Creating VPN configuration..."
@ -584,7 +592,7 @@ vpnsetup() {
install_vpn_pkgs_1 install_vpn_pkgs_1
install_vpn_pkgs_2 install_vpn_pkgs_2
install_fail2ban install_fail2ban
get_ikev2_script get_helper_scripts
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -251,6 +251,25 @@ install_fail2ban() {
) || exiterr2 ) || exiterr2
} }
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"
cd /opt/src || exit 1
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"
(
set -x
wget -t 3 -T 30 -q -O "$sc" "$dl_url"
) || /bin/rm -f "$sc"
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done
}
get_swan_ver() { get_swan_ver() {
SWAN_VER=4.6 SWAN_VER=4.6
base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0" base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0"
@ -323,17 +342,6 @@ EOF
fi fi
} }
get_ikev2_script() {
bigecho "Downloading IKEv2 script..."
cd /opt/src || exit 1
ikev2_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras/ikev2setup.sh"
(
set -x
wget -t 3 -T 30 -q -O ikev2.sh "$ikev2_url"
) || /bin/rm -f ikev2.sh
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
}
create_vpn_config() { create_vpn_config() {
bigecho "Creating VPN configuration..." bigecho "Creating VPN configuration..."
@ -702,7 +710,7 @@ vpnsetup() {
install_vpn_pkgs_2 install_vpn_pkgs_2
install_vpn_pkgs_3 install_vpn_pkgs_3
install_fail2ban install_fail2ban
get_ikev2_script get_helper_scripts
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config

View File

@ -231,6 +231,25 @@ install_fail2ban() {
) || exiterr2 ) || exiterr2
} }
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"
cd /opt/src || exit 1
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"
(
set -x
wget -t 3 -T 30 -q -O "$sc" "$dl_url"
) || /bin/rm -f "$sc"
[ -s "$sc" ] && chmod +x "$sc" && ln -s "/opt/src/$sc" /usr/bin 2>/dev/null
done
}
get_swan_ver() { get_swan_ver() {
SWAN_VER=4.6 SWAN_VER=4.6
base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0" base_url="https://github.com/hwdsl2/vpn-extras/releases/download/v1.0.0"
@ -311,17 +330,6 @@ EOF
fi fi
} }
get_ikev2_script() {
bigecho "Downloading IKEv2 script..."
cd /opt/src || exit 1
ikev2_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras/ikev2setup.sh"
(
set -x
wget -t 3 -T 30 -q -O ikev2.sh "$ikev2_url"
) || /bin/rm -f ikev2.sh
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
}
create_vpn_config() { create_vpn_config() {
bigecho "Creating VPN configuration..." bigecho "Creating VPN configuration..."
@ -687,7 +695,7 @@ vpnsetup() {
detect_ip detect_ip
install_vpn_pkgs install_vpn_pkgs
install_fail2ban install_fail2ban
get_ikev2_script get_helper_scripts
get_libreswan get_libreswan
install_libreswan install_libreswan
create_vpn_config create_vpn_config