add dhcp reload command
This commit is contained in:
parent
a9f49bc6f5
commit
757e0f8992
11
scripts/dhcp
11
scripts/dhcp
@ -27,6 +27,17 @@ class DhcpRegistry < Registry
|
||||
end
|
||||
dhcp_path = Pathname.new(File.expand_path("../../dhcp.peers.conf", __FILE__))
|
||||
File.open(dhcp_path, "w+").write(dhcp_template.render(leases: static_leases))
|
||||
|
||||
reload_dhcp
|
||||
end
|
||||
|
||||
def reload_dhcp
|
||||
command = try(data, "host", "reload_command")
|
||||
if command.nil?
|
||||
puts "skip to reload dhcpd because reload_command is not defined"
|
||||
else
|
||||
sh(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -113,9 +113,8 @@ class OpenvpnRegistry < Registry
|
||||
end
|
||||
|
||||
def service_command(command_type, peer_name)
|
||||
openvpn = @host["openvpn"] || {}
|
||||
cmd_name = "#{command_type}_command"
|
||||
command = openvpn[cmd_name]
|
||||
command = try(@host, "openvpn", cmd_name)
|
||||
if command.nil?
|
||||
puts "skip to #{command_type} openvpn because #{cmd_name} is not defined"
|
||||
else
|
||||
|
@ -41,6 +41,18 @@ def die(msg)
|
||||
exit(1)
|
||||
end
|
||||
|
||||
def try(hash, *args)
|
||||
result = hash
|
||||
args.each do |arg|
|
||||
if result.respond_to?(:[]) && result[arg]
|
||||
result = result[arg]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
class TemplateContext < OpenStruct
|
||||
def get_binding
|
||||
binding
|
||||
|
Loading…
Reference in New Issue
Block a user