37
cattools.sh
37
cattools.sh
@@ -137,13 +137,15 @@ network_wizard() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ condition_to_check_single_port_device ]; then
|
interfaces=$(ls /sys/class/net | grep -E 'eth[0-9]+')
|
||||||
read -p "检测到单网口设备,是否进行旁路网关设置?([Enter] 确认 / [0] 跳过旁路设置):" choice
|
iface_count=$(echo "$interfaces" | wc -w)
|
||||||
if [ "$choice" == "0" ]; then
|
|
||||||
echo "继续使用网络向导..."
|
if [ "$iface_count" -eq 1 ]; then
|
||||||
network_wizard
|
echo "Detected a single network interface /// 检测到单个网口"
|
||||||
else
|
read -p "是否进行旁路网关设置?([Enter] 确认 / [0] 跳过旁路设置):" choice
|
||||||
|
if [ "$choice" != "0" ]; then
|
||||||
bypass_gateway
|
bypass_gateway
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -183,7 +185,8 @@ network_wizard() {
|
|||||||
echo "PPPoE 拨号配置已完成"
|
echo "PPPoE 拨号配置已完成"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Use recommended DNS servers 223.6.6.6 119.29.29.99? /// 使用推荐的 DNS 服务器 223.6.6.6 119.29.29.99 吗?([Enter] 确认 / [0] 跳过): " use_dns
|
echo "Use recommended DNS servers 223.6.6.6 119.29.29.99?"
|
||||||
|
read -p " /// 使用推荐的 DNS 服务器 223.6.6.6 119.29.29.99 吗?([Enter] 确认 / [0] 跳过): " use_dns
|
||||||
if [ "$use_dns" = "0" ]; then
|
if [ "$use_dns" = "0" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
elif [ -z "$use_dns" ]; then
|
elif [ -z "$use_dns" ]; then
|
||||||
@@ -197,7 +200,8 @@ network_wizard() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Do you want to change the DHCP IP pool range? (default: 30-200) /// 是否修改 IP 可用段?(默认: 30-200 按 [Enter] 确认 / [1] 手动输入范围 ): " dhcp_choice
|
echo "Do you want to change the DHCP IP pool range? (default: 30-200)"
|
||||||
|
read -p " /// 是否修改 IP 可用段?(默认: 30-200 按 [Enter] 确认 / [1] 自定义范围 ): " dhcp_choice
|
||||||
if [ "$dhcp_choice" = "1" ]; then
|
if [ "$dhcp_choice" = "1" ]; then
|
||||||
read -p "Enter the DHCP IP pool range (e.g., 40-210) /// 输入 DHCP IP 地址范围 (例如: 40-210): " dhcp_range
|
read -p "Enter the DHCP IP pool range (e.g., 40-210) /// 输入 DHCP IP 地址范围 (例如: 40-210): " dhcp_range
|
||||||
if [[ $dhcp_range =~ ^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\-([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ ]]; then
|
if [[ $dhcp_range =~ ^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\-([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ ]]; then
|
||||||
@@ -237,7 +241,8 @@ network_wizard() {
|
|||||||
echo " eth0 eth1 ethx ..."
|
echo " eth0 eth1 ethx ..."
|
||||||
echo " □ □ □ ..."
|
echo " □ □ □ ..."
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Press Enter to configure network interfaces, press 1 to skip /// [Enter] 确认配置网口,按 [1] 跳过: " configure_network
|
echo "Press [Enter] to configure network interfaces, press [1] to skip"
|
||||||
|
read -p " /// [Enter] 确认配置网口,按 [1] 跳过: " configure_network
|
||||||
if [ "$configure_network" != "1" ]; then
|
if [ "$configure_network" != "1" ]; then
|
||||||
# 获取所有网口列表
|
# 获取所有网口列表
|
||||||
interfaces=$(ls /sys/class/net | grep -E 'eth[0-9]+')
|
interfaces=$(ls /sys/class/net | grep -E 'eth[0-9]+')
|
||||||
@@ -270,7 +275,7 @@ network_wizard() {
|
|||||||
echo "Skipping network interface configuration /// 跳过网口配置"
|
echo "Skipping network interface configuration /// 跳过网口配置"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "System architecture $arch is not supported by this script. No changes made. /// 系统架构 $arch 不支持该脚本。未进行任何更改。"
|
echo "System architecture $arch is not supported. No changes made. /// 系统架构 $arch 不支持该脚本。未进行任何更改。"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uci commit
|
uci commit
|
||||||
@@ -282,20 +287,12 @@ network_wizard() {
|
|||||||
|
|
||||||
# BypassGateway
|
# BypassGateway
|
||||||
bypass_gateway() {
|
bypass_gateway() {
|
||||||
ip="$1"
|
|
||||||
if echo "$ip" | grep -Eq '^(10|172\.(1[6-9]|2[0-9]|3[01])|192\.168)\.'; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 输入主路由的 IP 地址
|
# 输入主路由的 IP 地址
|
||||||
while true; do
|
while true; do
|
||||||
read -p "请输入主路由的 IP 地址(例如 192.168.31.1):" router_ip
|
read -p "请输入主路由的 IP 地址(例如 192.168.31.1):" router_ip
|
||||||
if [ -z "$router_ip" ]; then
|
if [ -z "$router_ip" ]; then
|
||||||
echo "主路由 IP 地址不能为空,请重新输入。"
|
echo "主路由 IP 地址不能为空,请重新输入。"
|
||||||
elif ! is_private_ip "$router_ip"; then
|
elif ! echo "$router_ip" | grep -Eq '^(10|172\.(1[6-9]|2[0-9]|3[01])|192\.168)\.'; then
|
||||||
echo "输入的 IP 地址无效,请输入有效的 IP 地址"
|
echo "输入的 IP 地址无效,请输入有效的 IP 地址"
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
@@ -311,7 +308,7 @@ bypass_gateway() {
|
|||||||
if [ -z "$device_ip" ]; then
|
if [ -z "$device_ip" ]; then
|
||||||
device_ip="$default_device_ip"
|
device_ip="$default_device_ip"
|
||||||
break
|
break
|
||||||
elif ! is_private_ip "$device_ip"; then
|
elif ! echo "$device_ip" | grep -Eq '^(10|172\.(1[6-9]|2[0-9]|3[01])|192\.168)\.'; then
|
||||||
echo "输入的 IP 地址无效,请输入有效的 IP 地址。"
|
echo "输入的 IP 地址无效,请输入有效的 IP 地址。"
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user