Skip to content

Commit

Permalink
lime-hwd-eth1-wan: generalized as lime-hwd-openwrt-wan
Browse files Browse the repository at this point in the history
lime-system: make a backup of original configuration at first boot
lime-hwd-tl_wdr3600: do not take charge of wan/lan configuration as lime-hwd-openwrt-wan does it
lime-full: depends on lime-hwd-openwrt-wan instead of lime-hwd-eth1-wan
  • Loading branch information
frank95 committed Aug 14, 2014
1 parent 4c38355 commit 3c9083c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 62 deletions.
2 changes: 1 addition & 1 deletion packages/lime-full/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define Package/$(PKG_NAME)
+lime-webui +luci-app-batman-adv +luci-app-bmx6 \
+lime-map-agent \
+lime-debug \
+lime-hwd-eth1-wan +lime-hwd-tl-wdr3600
+lime-hwd-openwrt-wan +lime-hwd-tl-wdr3600
endef

define Package/$(PKG_NAME)/description
Expand Down
33 changes: 0 additions & 33 deletions packages/lime-hwd-eth1-wan/src/eth1_wan.lua

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ LIME_CODENAME:=bigbang
GIT_COMMIT_DATE:=$(shell git log -n 1 --pretty=%ad --date=short . )
GIT_COMMIT_TSTAMP:=$(shell git log -n 1 --pretty=%at . )

PKG_NAME:=lime-hwd-eth1-wan
PKG_NAME:=lime-hwd-openwrt-wan
PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP)

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
TITLE:=Configure eth1 as wan interface if present
TITLE:=Respect openwrt wan interface as default
CATEGORY:=LiMe
URL:=http://libre-mesh.org
DEPENDS:=+lime-system +lua +libuci-lua
DEPENDS:=+lime-system +lua +libuci-lua +lime-proto-wan
endef

define Build/Compile
Expand All @@ -33,8 +33,8 @@ endef

define Package/$(PKG_NAME)/install
@mkdir -p $(1)/usr/lib/lua/lime/hwd || true
$(CP) ./build/eth1_wan.lua $(1)/usr/lib/lua/lime/hwd/eth1_wan.lua
@chmod +x $(1)/usr/lib/lua/lime/hwd/eth1_wan.lua
$(CP) ./build/openwrt_wan.lua $(1)/usr/lib/lua/lime/hwd/openwrt_wan.lua
@chmod +x $(1)/usr/lib/lua/lime/hwd/openwrt_wan.lua
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
41 changes: 41 additions & 0 deletions packages/lime-hwd-openwrt-wan/src/openwrt_wan.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/lua

local libuci = require("uci")
local hardware_detection = require("lime.hardware_detection")

local openwrt_wan = {}

openwrt_wan.sectionName = hardware_detection.sectionNamePrefix.."openwrt_wan"

function openwrt_wan.clean()
if config.autogenerable(openwrt_wan.sectionName) then config.delete(openwrt_wan.sectionName) end
end

function openwrt_wan.detect_hardware()
if config.autogenerable(openwrt_wan.sectionName) then
local uci_o = libuci:cursor()
uci_o:set_confdir("/etc/lime/config.original")
uci_o:set_savedir("/dev/null")
local ifname = uci_o:get("network", "wan", "ifname")
uci_o = nil
if ifname then
local protos = {}
for _, proto in pairs(config.get("network", "protocols")) do
if ( ( proto ~= "lan" ) and ( proto ~= "wan" ) ) then
table.insert(protos, proto)
end
end
table.insert(protos, "wan")

config.init_batch()
config.set(openwrt_wan.sectionName, "net")
config.set(openwrt_wan.sectionName, "autogenerated", "true")
config.set(openwrt_wan.sectionName, "protocols", protos)
config.set(openwrt_wan.sectionName, "linux_name", ifname)
config.end_batch()
end
end
end


return openwrt_wan
21 changes: 0 additions & 21 deletions packages/lime-hwd-tl-wdr3600/src/tl_wdr3600.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,6 @@ function tl_wdr3600.detect_hardware()
config.set(sectionName, "linux_name", linuxBaseIfname)
config.end_batch()
end

for vlanId=1,2 do
sectionName = tl_wdr3600.sectionNamePrefix..linuxBaseIfname.."vlan"..vlanId
if config.autogenerable(sectionName) then
local linux_name = linuxBaseIfname.."."..vlanId
local protos = {}

for _, proto in pairs(config.get("network", "protocols")) do
if ( vlanId == 1 and proto ~= "wan") or ( vlanId == 2 and proto ~= "lan") then
table.insert(protos, proto)
end
end

config.init_batch()
config.set(sectionName, "net")
config.set(sectionName, "autogenerated", "true")
config.set(sectionName, "protocols", protos)
config.set(sectionName, "linux_name", linux_name)
config.end_batch()
end
end
end

function tl_wdr3600.board_match()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
echo "Configuring LiMe for first time, will take apprex 2 minutes..."
(sleep 90s ; lua /usr/bin/lime-config && uci commit && reboot)&);
(sleep 90s ; cp -r /etc/config /etc/lime/config.original ; lua /usr/bin/lime-config && uci commit && reboot)&);
2 changes: 1 addition & 1 deletion packages/lime-system/files/usr/bin/lime-config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function main()
local modules_name = { "hardware_detection", "wireless", "network", "firewall", "system" }
local modules = {}
local modules = {}

for i, name in pairs(modules_name) do modules[i] = require("lime."..name) end
for _, module in pairs(modules) do module.clean() end
Expand Down

0 comments on commit 3c9083c

Please sign in to comment.