-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added openwisp-remove-default-wifi script #19
- Loading branch information
1 parent
dff12ee
commit f8037e6
Showing
7 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
openwisp-config/files/sbin/openwisp-remove-default-wifi.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env lua | ||
|
||
require('uci') | ||
|
||
-- parse arguments | ||
local arg={...} | ||
for key, value in pairs(arg) do | ||
-- test argument | ||
if value == '--test=1' then test = true; end | ||
end | ||
|
||
local standard_prefix = test and '../tests/' or '/etc/' | ||
local standard_path = standard_prefix .. 'config/' | ||
-- standard cursor | ||
local cursor = uci.cursor(standard_path) | ||
local changed = false | ||
|
||
cursor:foreach('wireless', 'wifi-iface', function(section) | ||
if section['.anonymous'] and | ||
section.encryption == 'none' and | ||
section.mode == 'ap' and | ||
(section.ssid == 'LEDE' or section.ssid == 'OpenWrt') | ||
then | ||
cursor:delete('wireless', section['.name']) | ||
changed = true | ||
end | ||
end) | ||
if changed then cursor:commit('wireless') end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
config wifi-device 'radio0' | ||
option path 'platform/ar934x_wmac' | ||
option disabled '1' | ||
option country 'IT' | ||
option phy 'phy0' | ||
option hwmode '11g' | ||
option channel '9' | ||
option type 'mac80211' | ||
option htmode 'HT20' | ||
|
||
config wifi-device 'radio1' | ||
option path 'pci0000:00/0000:00:00.0' | ||
option disabled '1' | ||
option country 'IT' | ||
option phy 'phy1' | ||
option hwmode '11a' | ||
option channel '48' | ||
option type 'mac80211' | ||
option htmode 'HT20' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- manually add lib dir to lua package path | ||
package.path = package.path .. ';../files/lib/?.lua' | ||
require('os') | ||
require('io') | ||
luaunit = require('luaunit') | ||
remove_default_wifi = assert(loadfile("../files/sbin/openwisp-remove-default-wifi.lua")) | ||
|
||
TestRemoveDefaultWifi = { | ||
setUp = function() | ||
os.execute('cp ./wifi/wireless ./config') | ||
end, | ||
tearDown = function() | ||
-- os.execute('rm ./config/wireless') | ||
end | ||
} | ||
|
||
function TestRemoveDefaultWifi.test_default() | ||
remove_default_wifi('--test=1') | ||
local file = io.open('./config/wireless') | ||
luaunit.assertNotNil(file) | ||
local contents = file:read('*all') | ||
luaunit.assertNil(string.find(contents, "option ssid 'LEDE'")) | ||
luaunit.assertNil(string.find(contents, "option ssid 'OpenWrt'")) | ||
end | ||
|
||
os.exit(luaunit.LuaUnit.run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
config wifi-device 'radio0' | ||
option path 'platform/ar934x_wmac' | ||
option disabled '1' | ||
option country 'IT' | ||
option phy 'phy0' | ||
option hwmode '11g' | ||
option channel '9' | ||
option type 'mac80211' | ||
option htmode 'HT20' | ||
|
||
config wifi-device 'radio1' | ||
option path 'pci0000:00/0000:00:00.0' | ||
option disabled '1' | ||
option country 'IT' | ||
option phy 'phy1' | ||
option hwmode '11a' | ||
option channel '48' | ||
option type 'mac80211' | ||
option htmode 'HT20' | ||
|
||
config wifi-iface | ||
option ssid 'LEDE' | ||
option encryption 'none' | ||
option device 'radio0' | ||
option mode 'ap' | ||
option network 'lan' | ||
|
||
config wifi-iface | ||
option ssid 'LEDE' | ||
option encryption 'none' | ||
option device 'radio1' | ||
option mode 'ap' | ||
option network 'lan' | ||
|
||
config wifi-iface | ||
option ssid 'OpenWrt' | ||
option encryption 'none' | ||
option device 'radio0' | ||
option mode 'ap' | ||
option network 'lan' | ||
|
||
config wifi-iface | ||
option ssid 'OpenWrt' | ||
option encryption 'none' | ||
option device 'radio1' | ||
option mode 'ap' | ||
option network 'lan' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters