Update 'root/etc/init.d/easymesh'

pull/1/head
ben 1 year ago
parent 72b83ab0c2
commit e5999e80a2

@ -265,64 +265,62 @@ set_easymesh() {
add_kvr add_kvr
add_dawn add_dawn
if [ "$ap_mode" = 1 ]; then
if [ "$ap_mode" = 1 ]; then
# Backup Configurations # Backup Configurations
cp /etc/config/wireless /etc/config/wireless.backup cp /etc/config/wireless /etc/config/wireless.backup
cp /etc/config/network /etc/config/network.backup cp /etc/config/network /etc/config/network.backup
cp /etc/config/dhcp /etc/config/dhcp.backup cp /etc/config/dhcp /etc/config/dhcp.backup
# Generate a random IP in the same subnet
ip_base=$(echo "$dns" | cut -d'.' -f1-3) # Get the first three octets of the DNS IP
last_octet=$((RANDOM % 254 + 1)) # Generate a random value for the last octet between 1 and 254
nodeip="${ip_base}.${last_octet}" # Concatenate the base IP with the new last octet
# Configure Bridge and Interfaces # Configure Bridge and Interfaces
uci set network.lan.type='bridge' uci set network.lan.type='bridge'
uci set network.lan.ifname="$(uci get network.lan.ifname) $(uci get network.wan.ifname)" uci set network.lan.ifname='eth0' # assuming eth0 is the LAN interface
uci del network.wan.ifname uci set network.lan.proto='static'
uci set wireless.mesh_$apall.mesh_fwding='1' uci set network.lan.ipaddr=$nodeip # Set the randomly chosen IP
uci set network.lan.netmask='255.255.255.0' # Set your desired netmask
uci set network.lan.gateway=$dns # Set the gateway IP (usually your main router IP)
uci set network.lan.dns=$dns # Set the DNS IP
uci set system.@system[0].hostname=$gateway
# Disable dnsmasq # Add the Wi-Fi interface to the LAN bridge
uci set wireless.default_$apall.network='lan' # Adjust if your wireless interface name differs
# Disable and stop dnsmasq
uci commit dhcp; echo '' > /etc/config/dhcp uci commit dhcp; echo '' > /etc/config/dhcp
/etc/init.d/dnsmasq disable /etc/init.d/dnsmasq disable
/etc/init.d/dnsmasq stop /etc/init.d/dnsmasq stop
# Switch LAN to DHCP Client # Delete existing WAN interface
echo "Switching the LAN interface to DHCP client" uci delete network.wan
uci del network.lan.broadcast
uci del network.lan.dns
uci del network.lan.gateway
uci del network.lan.ipaddr
uci del network.lan.netmask
uci set network.lan.proto='dhcp'
uci set system.@system[0].hostname=$gateway
uci set network.lan.hostname="`uci get system.@system[0].hostname`"
# Add WAN to br-lan bridge
echo "Adding WAN to br-lan bridge"
uci set network.lan.ifname="$(uci get network.lan.ifname) eth1" # assuming eth1 is your WAN interface
uci commit network
# Delete WAN zone from firewall # Delete WAN zone from firewall
echo "Deleting the WAN zone from the firewall"
wan_zone=$(uci show firewall | grep '=zone' | grep '.name=' | grep 'wan' | cut -d'.' -f2) wan_zone=$(uci show firewall | grep '=zone' | grep '.name=' | grep 'wan' | cut -d'.' -f2)
if [ ! -z "$wan_zone" ]; then if [ ! -z "$wan_zone" ]; then
uci delete firewall.$wan_zone uci delete firewall.$wan_zone
echo "WAN zone deleted"
else
echo "No WAN zone found"
fi fi
# Adjust the firewall settings as necessary
# Commit the changes # Commit the changes
uci commit firewall uci commit firewall
uci commit network uci commit network
uci commit wireless
# Commit Changes and Restart Network uci commit system
uci commit # Restart services to apply changes
sync sync
/etc/init.d/network restart /etc/init.d/network restart
/etc/init.d/wireless restart
# Reboot the device /etc/init.d/system reload
#echo "Please reboot the device..."
#reboot
fi fi
else else
ap_mode_stop ap_mode_stop

Loading…
Cancel
Save