First pass fixing set apmode

main
Jason Hawks 10 months ago
parent 750ce5b6e5
commit 02799a6359

@ -206,7 +206,7 @@ o:depends("role", "off")
btnAPMode = s:taboption("apmode", Button, "_btn_apmode", translate("Join Mesh Network"), translate("WARNING: THIS WILL CHANGE THIS NODE'S IP ADDRESS, YOU WILL LOOSE ACCESS TO THIS UI"))
function btnAPMode.write()
luci.sys.call("bash /easymesh/dumbap.sh")
io.popen("/easymesh/easymesh.sh dumbap &")
end
btnAPMode:depends("role", "off")
---- ip address
@ -234,9 +234,9 @@ ctrl.addremove = false
function m.on_after_commit(self)
local enabled = m:formvalue("cbid.easymesh.easymesh.enabled")
if enabled and enabled == "1" then
luci.sys.call("bash /easymesh/easymesh.sh start &")
luci.sys.call("/easymesh/easymesh.sh &")
else
luci.sys.call("bash /easymesh/easymesh.sh stop &")
luci.sys.call("/easymesh/easymesh.sh &")
end
end

@ -1,107 +0,0 @@
#!/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
}
set_apmode

@ -1,5 +1,110 @@
#!/bin/bash
# Dumb AP Mode Block
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
}
clear_mesh_radio() {
# Get the radio to be used for mesh from the config
AP_RADIO=$(uci -q get easymesh.config.apRadio)
@ -304,6 +409,11 @@ disable_easymesh() {
uci del easymesh.config.running
}
if [ "$1" = "dumbap" ]; then
set_apmode
exit 0
fi
# Check if enabled
if [ "$(uci -q get easymesh.config.enabled)" = 1 ]; then
enable_easymesh

Loading…
Cancel
Save