#!/bin/sh # 设置默认防火墙规则,方便虚拟机首次访问 WebUI uci set firewall.@zone[1].input='ACCEPT' # 设置主机名映射,解决安卓原生 TV 无法联网的问题 uci add dhcp domain uci set "dhcp.@domain[-1].name=time.android.com" uci set "dhcp.@domain[-1].ip=203.107.6.88" # 计算网卡数量 count=0 for iface in /sys/class/net/*; do iface_name=$(basename "$iface") # 检查是否为物理网卡(排除回环设备和无线设备) if [ -e "$iface/device" ] && echo "$iface_name" | grep -Eq '^eth|^en'; then count=$((count + 1)) fi done # 网络设置 if [ "$count" -eq 1 ]; then # 单网口设备 NAS模式 uci set network.lan.proto='dhcp' elif [ "$count" -gt 1 ]; then # 多网口设备 uci set network.lan.ipaddr='192.168.8.1' # 判断是否启用 PPPoE if [[ "$ENABLE_PPPOE" == "yes" ]]; then echo "PPPoE is enabled." # 设置拨号信息 uci set network.wan.proto='pppoe' uci set network.wan.username=$PPPOE_ACCOUNT uci set network.wan.password=$PPPOE_PASSWORD uci set network.wan.peerdns='1' uci set network.wan.auto='1' echo "PPPoE configuration completed successfully." else echo "PPPoE is not enabled. Skipping configuration." fi fi # 设置所有网口可访问网页终端 uci delete ttyd.@ttyd[0].interface # 设置所有网口可连接 SSH uci set dropbear.@dropbear[0].Interface='' uci commit # 设置编译作者信息 FILE_PATH="/etc/openwrt_release" NEW_DESCRIPTION="Compiled by wukongdaily" sed -i "s/DISTRIB_DESCRIPTION='[^']*'/DISTRIB_DESCRIPTION='$NEW_DESCRIPTION'/" "$FILE_PATH" exit 0