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
|
end
|
||||||
dhcp_path = Pathname.new(File.expand_path("../../dhcp.peers.conf", __FILE__))
|
dhcp_path = Pathname.new(File.expand_path("../../dhcp.peers.conf", __FILE__))
|
||||||
File.open(dhcp_path, "w+").write(dhcp_template.render(leases: static_leases))
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,9 +113,8 @@ class OpenvpnRegistry < Registry
|
|||||||
end
|
end
|
||||||
|
|
||||||
def service_command(command_type, peer_name)
|
def service_command(command_type, peer_name)
|
||||||
openvpn = @host["openvpn"] || {}
|
|
||||||
cmd_name = "#{command_type}_command"
|
cmd_name = "#{command_type}_command"
|
||||||
command = openvpn[cmd_name]
|
command = try(@host, "openvpn", cmd_name)
|
||||||
if command.nil?
|
if command.nil?
|
||||||
puts "skip to #{command_type} openvpn because #{cmd_name} is not defined"
|
puts "skip to #{command_type} openvpn because #{cmd_name} is not defined"
|
||||||
else
|
else
|
||||||
|
@ -41,6 +41,18 @@ def die(msg)
|
|||||||
exit(1)
|
exit(1)
|
||||||
end
|
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
|
class TemplateContext < OpenStruct
|
||||||
def get_binding
|
def get_binding
|
||||||
binding
|
binding
|
||||||
|
Loading…
Reference in New Issue
Block a user