2015-11-02 04:37:27 +02:00
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
CONFIGURATIONS = YAML.load_file('configurations.yml')['configurations']
|
|
|
|
CONFIG_DIR = File.expand_path(File.dirname(__FILE__))
|
|
|
|
OUT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "out"))
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
def mixins(name)
|
|
|
|
CONFIGURATIONS[name]['mixins'].each do |mixin|
|
|
|
|
`cp -rp #{CONFIG_DIR}/files/#{mixin}/* #{OUT_DIR}/#{name}/files`
|
2015-11-02 04:37:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
def wifi(name)
|
|
|
|
config_path = File.join(OUT_DIR, name, "/files/etc/config/wireless")
|
|
|
|
wlans = CONFIGURATIONS[name]['wlans']
|
2015-11-02 04:37:27 +02:00
|
|
|
wlan_config = File.read(config_path)
|
|
|
|
|
|
|
|
wlans.each do |id, wlan|
|
|
|
|
wlan_config.sub!("<radio#{id}-channel>", wlan['channel'].to_s)
|
|
|
|
wlan_config.sub!("<wlan#{id}-macaddr>", wlan['bssid'].to_s)
|
|
|
|
end
|
2016-11-02 18:02:36 +02:00
|
|
|
#wlan_config.gsub!("# option channel", " option channel")
|
2015-11-02 04:37:27 +02:00
|
|
|
wlan_config.gsub!("# option macaddr", " option macaddr")
|
|
|
|
|
|
|
|
File.open(config_path, 'w') do |f|
|
|
|
|
f.puts wlan_config
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
def hostname(name)
|
|
|
|
`sed -i "s/<hostname>/#{name}/g" #{OUT_DIR}/#{name}/files/etc/config/system`
|
|
|
|
`sed -i "s/<hostname>/#{name}/g" #{OUT_DIR}/#{name}/files/etc/collectd.conf`
|
2015-11-02 04:37:27 +02:00
|
|
|
end
|
|
|
|
|
2016-11-02 18:02:36 +02:00
|
|
|
def ip(name)
|
|
|
|
ip = CONFIGURATIONS[name]['ip']
|
|
|
|
`sed -i "s/<ip>/#{ip}/g" #{OUT_DIR}/#{name}/files/etc/config/network`
|
|
|
|
end
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
def config(name)
|
|
|
|
config = CONFIGURATIONS[name]['config']
|
2016-11-02 18:02:36 +02:00
|
|
|
`cp #{File.join(CONFIG_DIR, "%s.configdiff" % config)} #{File.join(OUT_DIR, name, '.config')}`
|
2015-11-02 04:37:27 +02:00
|
|
|
end
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
def outdir(name)
|
|
|
|
`mkdir -p #{File.join(OUT_DIR, name, 'files')}`
|
2015-11-02 04:37:27 +02:00
|
|
|
end
|
|
|
|
|
2015-11-04 16:10:17 +02:00
|
|
|
task :ap, [:name] do |t, args|
|
|
|
|
outdir args.name
|
|
|
|
mixins args.name
|
|
|
|
hostname args.name
|
|
|
|
wifi args.name
|
2016-11-02 18:02:36 +02:00
|
|
|
ip args.name
|
|
|
|
config args.name
|
2015-11-04 16:10:17 +02:00
|
|
|
end
|
2015-11-02 04:37:27 +02:00
|
|
|
|
|
|
|
task :all do
|
2016-11-03 00:35:15 +02:00
|
|
|
aps = %W(ap-l0-1 ap-l0-2 ap-l1-1 ap-l1-2 )
|
|
|
|
# aps = %W(ap-bulgaria-1-ac ap-bulgaria-2-ac ap-bulgaria-3-ac ap-chamber-1-ac ap-chamber-2-ac ap-marble-1-ac ap-music-1-ac ap-lobby1-1-an ap-lobby1-2-legacy)
|
|
|
|
# aps = %W(ap-lobby1-3-an)
|
|
|
|
# aps = %W(ap-lobby2-1-an)
|
|
|
|
# aps = %W(ap-bulgaria-4-legacy)
|
2015-11-04 16:10:17 +02:00
|
|
|
|
|
|
|
aps.each do |ap|
|
|
|
|
Rake::Task["ap"].reenable
|
|
|
|
Rake::Task["ap"].invoke ap
|
|
|
|
end
|
2015-11-02 04:37:27 +02:00
|
|
|
end
|