Makefile upped, dumbap not working yet, easymesh now checks enable flag
parent
f7521c5bb5
commit
8795a06651
@ -0,0 +1,105 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set_apmode() {
|
||||||
|
AP_MODE=$(uci -q get easymesh.config.ap_mode)
|
||||||
|
if [ "$AP_MODE" = 1 ]; then
|
||||||
|
# Set a flag to indicate that we are in AP mode
|
||||||
|
# When we go to disable easymesh, we will check this flag and if it was set we restore settings
|
||||||
|
uci set easymesh.config.ap_mode_enabled=1
|
||||||
|
|
||||||
|
# Backup our configs
|
||||||
|
rm /etc/config/*.meshbak
|
||||||
|
cp /etc/config/wireless /etc/config/wireless.meshbak
|
||||||
|
cp /etc/config/network /etc/config/network.meshbak
|
||||||
|
cp /etc/config/dhcp /etc/config/dhcp.meshbak
|
||||||
|
|
||||||
|
# Disabling and stopping services not needed
|
||||||
|
for service in firewall dnsmasq odhcpd; do
|
||||||
|
if /etc/init.d/$service enabled; then
|
||||||
|
echo "Disabling and stopping $service..."
|
||||||
|
/etc/init.d/$service disable
|
||||||
|
/etc/init.d/$service stop
|
||||||
|
else
|
||||||
|
echo "$service is not enabled, skipping..."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set LAN interface to DHCP client
|
||||||
|
uci del network.lan.ipaddr
|
||||||
|
uci del network.lan.netmask
|
||||||
|
uci set network.lan.proto='dhcp'
|
||||||
|
uci del network.wan
|
||||||
|
uci del network.wan6
|
||||||
|
|
||||||
|
# Fix firewall to be disabled
|
||||||
|
uci del firewall.lan.network
|
||||||
|
uci del firewall.wan.network
|
||||||
|
|
||||||
|
# Fix dhcp to be disabled
|
||||||
|
uci set dhcp.lan.ignore='1'
|
||||||
|
uci del dhcp.wan
|
||||||
|
|
||||||
|
# Fix this for proper variable name
|
||||||
|
HOSTNAME=$(uci -q get easymesh.config.hostname)
|
||||||
|
# Set netmask and gateway (assuming $netmask and $dns didn't break more stuff)
|
||||||
|
uci set system.@system[0].hostname=$HOSTNAME
|
||||||
|
|
||||||
|
# Retrieve the list of ports for network.@device[0]
|
||||||
|
LAN_PORTS=$(uci get network.@device[0].ports)
|
||||||
|
|
||||||
|
# Check if 'wan' is already in the list of ports
|
||||||
|
if echo "$LAN_PORTS" | grep -q -w 'wan'; then
|
||||||
|
echo "'wan' is already in the list of ports for lan."
|
||||||
|
else
|
||||||
|
echo "'wan' is not in the list. Adding it to lan ports..."
|
||||||
|
uci add_list network.@device[0].ports='wan'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the radio to be used for mesh from the config
|
||||||
|
AP_RADIO=$(uci -q get easymesh.config.apRadio)
|
||||||
|
|
||||||
|
# # Loop through the selected radios
|
||||||
|
# for CURRENT_RADIO in $AP_RADIO; do
|
||||||
|
# echo "Multiple Radio Setup, Current Radio: $CURRENT_RADIO"
|
||||||
|
# # Extact the radio number from the radio name
|
||||||
|
# wifi_num="${cur_radio#CURRENT_RADIO}"
|
||||||
|
# uci set wireless.wifinet${wifi_num}.network="lan private_router_batman"
|
||||||
|
# done
|
||||||
|
|
||||||
|
uci commit
|
||||||
|
# Tell openwrt to reload the configs
|
||||||
|
reload_config
|
||||||
|
/etc/init.d/network reload
|
||||||
|
else
|
||||||
|
# Set a flag to indicate that we are in AP mode
|
||||||
|
uci set easymesh.config.ap_mode_enabled=0
|
||||||
|
|
||||||
|
# Restore our configs
|
||||||
|
[ -f /etc/config/wireless.meshbak ] && {
|
||||||
|
mv /etc/config/wireless /etc/config/wireless.dumbap
|
||||||
|
cp /etc/config/wireless.meshbak /etc/config/wireless
|
||||||
|
}
|
||||||
|
[ -f /etc/config/network.meshbak ] && {
|
||||||
|
mv /etc/config/network /etc/config/network.dumbap
|
||||||
|
cp /etc/config/network.meshbak /etc/config/network
|
||||||
|
}
|
||||||
|
[ -f /etc/config/dhcp.meshbak ] && {
|
||||||
|
mv /etc/config/dhcp /etc/config/dhcp.dumbap
|
||||||
|
cp /etc/config/dhcp.meshbak /etc/config/dhcp
|
||||||
|
}
|
||||||
|
|
||||||
|
# Enable and start services not needed
|
||||||
|
for service in firewall dnsmasq odhcpd; do
|
||||||
|
if /etc/init.d/$service disabled; then
|
||||||
|
echo "Enabling and starting $service..."
|
||||||
|
/etc/init.d/$service enable
|
||||||
|
/etc/init.d/$service start
|
||||||
|
else
|
||||||
|
echo "$service is not disabled, skipping..."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
reload_config
|
||||||
|
/etc/init.d/network reload
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in New Issue