gluon-mesh-batman-adv: convert generated upgrade scripts to Lua

This commit is contained in:
Matthias Schiffer 2014-05-14 11:54:07 +02:00
parent b95a4d67e8
commit a6f87d2461
3 changed files with 70 additions and 70 deletions

View File

@ -1,8 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-mesh-batman-adv PKG_NAME:=gluon-mesh-batman-adv
PKG_VERSION:=1 PKG_VERSION:=2
PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION)
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
@ -31,7 +30,6 @@ endef
define Package/gluon-mesh-batman-adv/install define Package/gluon-mesh-batman-adv/install
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
$(GLUON_GENERATE) ./generate/* $(1)/
endef endef
$(eval $(call BuildPackage,gluon-mesh-batman-adv)) $(eval $(call BuildPackage,gluon-mesh-batman-adv))

View File

@ -0,0 +1,69 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
local c = uci.cursor()
local function configure_radio(device)
local radio = device['.name']
local hwmode = c:get('wireless', radio, 'hwmode')
local config
if hwmode == '11g' or hwmode == '11ng' then
config = site.wifi24
elseif hwmode == '11a' or hwmode == '11na' then
config = site.wifi5
else
return true
end
c:delete('wireless', radio, 'disabled')
c:set('wireless', radio, 'channel', config.channel)
c:set('wireless', radio, 'htmode', config.htmode)
c:set('wireless', radio, 'country', site.regdom)
local client = 'client_' .. radio
c:delete('wireless', client)
c:section('wireless', 'wifi-iface', client,
{
device = radio,
network = 'client',
mode = 'ap',
ssid = config.ssid,
}
)
local mesh = 'mesh_' .. radio
c:delete('network', mesh)
c:section('network', 'interface', mesh,
{
proto = 'batadv',
mtu = '1528',
mesh = 'bat0',
}
)
c:delete('wireless', mesh)
c:section('wireless', 'wifi-iface', mesh,
{
device = radio,
network = mesh,
mode = 'adhoc',
ssid = config.mesh_ssid,
bssid = config.mesh_bssid,
mcast_rate = config.mesh_mcast_rate,
}
)
return true
end
c:foreach('wireless', 'wifi-device', configure_radio)
c:save('wireless')
c:save('network')
c:commit('wireless')
c:commit('network')

View File

@ -1,67 +0,0 @@
#!/bin/sh
. /lib/functions.sh
config_load wireless
configure_radio() {
local radio="$1"
local channel; local htmode; local ssid; local mesh_ssid; local mesh_bssid; local mesh_mcast_rate
config_get hwmode "$radio" 'hwmode'
case "$hwmode" in
11g|11ng)
channel='@wifi24.channel@'
htmode='@wifi24.htmode@'
ssid='@wifi24.ssid@'
mesh_ssid='@wifi24.mesh_ssid@'
mesh_bssid='@wifi24.mesh_bssid@'
mesh_mcast_rate='@wifi24.mesh_mcast_rate@'
;;
11a|11na)
channel='@wifi5.channel@'
htmode='@wifi5.htmode@'
ssid='@wifi5.ssid@'
mesh_ssid='@wifi5.mesh_ssid@'
mesh_bssid='@wifi5.mesh_bssid@'
mesh_mcast_rate='@wifi5.mesh_mcast_rate@'
;;
*)
return
esac
uci_remove wireless "$radio" 'disabled'
uci_set wireless "$radio" channel "$channel"
uci_set wireless "$radio" htmode "$htmode"
uci_set wireless "$radio" country '@regdom@'
uci_remove wireless "client_${radio}"
uci_add wireless 'wifi-iface' "client_${radio}"
uci_set wireless "client_${radio}" device "$radio"
uci_set wireless "client_${radio}" network 'client'
uci_set wireless "client_${radio}" mode 'ap'
uci_set wireless "client_${radio}" ssid "$ssid"
uci_remove network "mesh_${radio}"
uci_add network 'interface' "mesh_${radio}"
uci_set network "mesh_${radio}" proto 'batadv'
uci_set network "mesh_${radio}" mtu '1528'
uci_set network "mesh_${radio}" mesh 'bat0'
uci_remove wireless "mesh_${radio}"
uci_add wireless 'wifi-iface' "mesh_${radio}"
uci_set wireless "mesh_${radio}" device "$radio"
uci_set wireless "mesh_${radio}" network "mesh_${radio}"
uci_set wireless "mesh_${radio}" mode 'adhoc'
uci_set wireless "mesh_${radio}" ssid "$mesh_ssid"
uci_set wireless "mesh_${radio}" bssid "$mesh_bssid"
uci_set wireless "mesh_${radio}" mcast_rate "$mesh_mcast_rate"
}
config_foreach configure_radio 'wifi-device'
uci_commit wireless
uci_commit network