refactor: move add tunnel to function

This commit is contained in:
Slava-Shchipunov
2024-11-03 22:13:16 +07:00
parent ee6bbe3f13
commit fe245c31c3

View File

@@ -25,74 +25,78 @@ else
[ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp [ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp
fi fi
echo "What type of VPN or proxy will be used?" add_tunnel() {
echo "1) VLESS, Shadowsocks (A sing-box will be installed)" echo "What type of VPN or proxy will be used?"
echo "2) Wireguard" echo "1) VLESS, Shadowsocks (A sing-box will be installed)"
echo "3) AmneziaWG" echo "2) Wireguard"
echo "4) OpenVPN" echo "3) AmneziaWG"
echo "5) OpenConnect" echo "4) OpenVPN"
echo "6) Skip this step" echo "5) OpenConnect"
echo "6) Skip this step"
while true; do while true; do
read -r -p '' TUNNEL read -r -p '' TUNNEL
case $TUNNEL in case $TUNNEL in
1) 1)
opkg install sing-box opkg install sing-box
break break
;; ;;
2) 2)
opkg install wireguard-tools luci-proto-wireguard luci-app-wireguard opkg install wireguard-tools luci-proto-wireguard luci-app-wireguard
printf "\033[32;1mDo you want to configure the wireguard interface? (y/n): \033[0m\n" printf "\033[32;1mDo you want to configure the wireguard interface? (y/n): \033[0m\n"
read IS_SHOULD_CONFIGURE_WG_INTERFACE read IS_SHOULD_CONFIGURE_WG_INTERFACE
if [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "y" ] || [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "Y" ]; then if [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "y" ] || [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "Y" ]; then
sh <(wget -O - "$BASE_RAW_URL/utils/wg-awg-setup.sh") Wireguard sh <(wget -O - "$BASE_RAW_URL/utils/wg-awg-setup.sh") Wireguard
else else
printf "\e[1;32mUse these instructions to manual configure https://itdog.info/nastrojka-klienta-wireguard-na-openwrt/\e[0m\n" printf "\e[1;32mUse these instructions to manual configure https://itdog.info/nastrojka-klienta-wireguard-na-openwrt/\e[0m\n"
fi fi
break break
;; ;;
3) 3)
sh <(wget -O - "$BASE_RAW_URL/utils/amneziawg-install.sh") sh <(wget -O - "$BASE_RAW_URL/utils/amneziawg-install.sh")
printf "\033[32;1mThere are no instructions for manual configure yet. Do you want to configure the amneziawg interface? (y/n): \033[0m\n" printf "\033[32;1mThere are no instructions for manual configure yet. Do you want to configure the amneziawg interface? (y/n): \033[0m\n"
read IS_SHOULD_CONFIGURE_WG_INTERFACE read IS_SHOULD_CONFIGURE_WG_INTERFACE
if [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "y" ] || [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "Y" ]; then if [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "y" ] || [ "$IS_SHOULD_CONFIGURE_WG_INTERFACE" = "Y" ]; then
sh <(wget -O - "$BASE_RAW_URL/utils/wg-awg-setup.sh") AmneziaWG sh <(wget -O - "$BASE_RAW_URL/utils/wg-awg-setup.sh") AmneziaWG
fi fi
break break
;; ;;
4) 4)
opkg install opkg install openvpn-openssl luci-app-openvpn opkg install opkg install openvpn-openssl luci-app-openvpn
printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openvpn-na-openwrt/\e[0m\n" printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openvpn-na-openwrt/\e[0m\n"
break break
;; ;;
5) 5)
opkg install opkg install openconnect luci-proto-openconnect opkg install opkg install openconnect luci-proto-openconnect
printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openconnect-na-openwrt/\e[0m\n" printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openconnect-na-openwrt/\e[0m\n"
break break
;; ;;
6) 6)
echo "Skip. Use this if you're installing an upgrade." echo "Skip. Use this if you're installing an upgrade."
break break
;; ;;
*) *)
echo "Choose from the following options" echo "Choose from the following options"
;; ;;
esac esac
done done
}
add_tunnel
echo "Installed podkop..." echo "Installed podkop..."
opkg install $DOWNLOAD_DIR/podkop*.ipk opkg install $DOWNLOAD_DIR/podkop*.ipk