Rake tasks -> methods
This commit is contained in:
parent
a714cb4fac
commit
699a62daf5
43
Rakefile
43
Rakefile
|
@ -4,15 +4,15 @@ CONFIGURATIONS = YAML.load_file('configurations.yml')['configurations']
|
||||||
CONFIG_DIR = File.expand_path(File.dirname(__FILE__))
|
CONFIG_DIR = File.expand_path(File.dirname(__FILE__))
|
||||||
OUT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "out"))
|
OUT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "out"))
|
||||||
|
|
||||||
task :mixins, [:name] do |t, args|
|
def mixins(name)
|
||||||
CONFIGURATIONS[args.name]['mixins'].each do |mixin|
|
CONFIGURATIONS[name]['mixins'].each do |mixin|
|
||||||
`cp -rp #{CONFIG_DIR}/files/#{mixin}/* #{OUT_DIR}/#{args.name}/files`
|
`cp -rp #{CONFIG_DIR}/files/#{mixin}/* #{OUT_DIR}/#{name}/files`
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :wifi, [:name] do |t, args|
|
def wifi(name)
|
||||||
config_path = File.join(OUT_DIR, args.name, "/files/etc/config/wireless")
|
config_path = File.join(OUT_DIR, name, "/files/etc/config/wireless")
|
||||||
wlans = CONFIGURATIONS[args.name]['wlans']
|
wlans = CONFIGURATIONS[name]['wlans']
|
||||||
wlan_config = File.read(config_path)
|
wlan_config = File.read(config_path)
|
||||||
|
|
||||||
wlans.each do |id, wlan|
|
wlans.each do |id, wlan|
|
||||||
|
@ -27,23 +27,32 @@ task :wifi, [:name] do |t, args|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :hostname, [:name] do |t, args|
|
def hostname(name)
|
||||||
`sed -i "s/<hostname>/#{args.name}/g" #{OUT_DIR}/#{args.name}/files/etc/config/system`
|
`sed -i "s/<hostname>/#{name}/g" #{OUT_DIR}/#{name}/files/etc/config/system`
|
||||||
`sed -i "s/<hostname>/#{args.name}/g" #{OUT_DIR}/#{args.name}/files/etc/collectd.conf`
|
`sed -i "s/<hostname>/#{name}/g" #{OUT_DIR}/#{name}/files/etc/collectd.conf`
|
||||||
end
|
end
|
||||||
|
|
||||||
task :config, [:name] do |t, args|
|
def config(name)
|
||||||
config = CONFIGURATIONS[args.name]['config']
|
config = CONFIGURATIONS[name]['config']
|
||||||
`cp #{File.join(CONFIG_DIR, "%s.configdiff" % config)} #{File.join(OUT_DIR, args.name)}`
|
`cp #{File.join(CONFIG_DIR, "%s.configdiff" % config)} #{File.join(OUT_DIR, name)}`
|
||||||
end
|
end
|
||||||
|
|
||||||
task :outdir, [:name] do |t, args|
|
def outdir(name)
|
||||||
`mkdir -p #{File.join(OUT_DIR, args.name, 'files')}`
|
`mkdir -p #{File.join(OUT_DIR, name, 'files')}`
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'shit'
|
task :ap, [:name] do |t, args|
|
||||||
task :ap, [:name] => [:outdir, :mixins, :hostname, :wifi]
|
outdir args.name
|
||||||
|
mixins args.name
|
||||||
|
hostname args.name
|
||||||
|
wifi args.name
|
||||||
|
end
|
||||||
|
|
||||||
task :all do
|
task :all do
|
||||||
Rake::Task["ap"].invoke 'ap-bulgaria-1-ac'
|
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)
|
||||||
|
|
||||||
|
aps.each do |ap|
|
||||||
|
Rake::Task["ap"].reenable
|
||||||
|
Rake::Task["ap"].invoke ap
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue