Client: can be built again. Add a makefile rule to generate all zones.
This commit is contained in:
parent
1f69839333
commit
4606f852cc
5 changed files with 34 additions and 17 deletions
3
Makefile
3
Makefile
|
@ -64,6 +64,9 @@ run-client-rr-update-a:
|
||||||
run-client-rr-del:
|
run-client-rr-del:
|
||||||
$(Q)$(LD_P) ./bin/dnsmanager-client user rr del $(DOMAIN) $(RRID) $(LOGIN_OPT)
|
$(Q)$(LD_P) ./bin/dnsmanager-client user rr del $(DOMAIN) $(RRID) $(LOGIN_OPT)
|
||||||
|
|
||||||
|
run-admin-generate-all-zonefiles:
|
||||||
|
$(Q)$(LD_P) ./bin/dnsmanager-client admin genall $(LOGIN_OPT)
|
||||||
|
|
||||||
##################
|
##################
|
||||||
### SETUP COMMANDS
|
### SETUP COMMANDS
|
||||||
##################
|
##################
|
||||||
|
|
|
@ -59,11 +59,13 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
|
||||||
# either we test with the exact expected number of arguments or the least.
|
# either we test with the exact expected number of arguments or the least.
|
||||||
if exact = nexact
|
if exact = nexact
|
||||||
if args.size != exact
|
if args.size != exact
|
||||||
|
Baguette::Log.error "Wrong number of parameters: expected #{exact}, got #{args.size}"
|
||||||
Baguette::Log.error "#{parser}"
|
Baguette::Log.error "#{parser}"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
elsif least = at_least
|
elsif least = at_least
|
||||||
if args.size < least
|
if args.size < least
|
||||||
|
Baguette::Log.error "Wrong number of parameters: expected at least #{least}, got #{args.size}"
|
||||||
Baguette::Log.error "#{parser}"
|
Baguette::Log.error "#{parser}"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
5
src/service.cr
Normal file
5
src/service.cr
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
require "ipc"
|
||||||
|
|
||||||
|
# Useful to enable the client to be built.
|
||||||
|
class DNSManager::Service < IPC
|
||||||
|
end
|
|
@ -2,11 +2,10 @@ require "json"
|
||||||
require "uuid"
|
require "uuid"
|
||||||
require "uuid/json"
|
require "uuid/json"
|
||||||
require "baguette-crystal-base"
|
require "baguette-crystal-base"
|
||||||
|
require "./service.cr"
|
||||||
|
|
||||||
require "dodb"
|
require "dodb"
|
||||||
|
|
||||||
alias UserDataID = UInt32
|
|
||||||
|
|
||||||
class DNSManager::Storage
|
class DNSManager::Storage
|
||||||
getter domains : DODB::CachedDataBase(Domain)
|
getter domains : DODB::CachedDataBase(Domain)
|
||||||
getter domains_by_name : DODB::Index(Domain)
|
getter domains_by_name : DODB::Index(Domain)
|
||||||
|
@ -72,26 +71,33 @@ class DNSManager::Storage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only an admin can access this function.
|
def generate_zonefile_(domain : String) : Nil
|
||||||
def generate_all_zonefiles() : IPC::JSON
|
zone = zone_must_exist! domain
|
||||||
Baguette::Log.info "writing all zone files in #{@zonefiledir}/"
|
|
||||||
zones.each do |zone|
|
# Safe write.
|
||||||
# TODO: safe write.
|
filename_final = "#{@zonefiledir}/#{zone.domain}"
|
||||||
File.open("#{@zonefiledir}/#{zone.domain}", "w") do |file|
|
filename_wip = "#{filename_final}.wip"
|
||||||
zone.to_bind9 file
|
Baguette::Log.info "writing zone file #{filename_final}"
|
||||||
end
|
|
||||||
|
File.open(filename_wip, "w") do |file|
|
||||||
|
zone.to_bind9 file
|
||||||
end
|
end
|
||||||
Response::Success.new
|
|
||||||
|
# Rename WIP filename to final file name.
|
||||||
|
File.rename filename_wip, filename_final
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only an admin can access this function.
|
# Only an admin can access this function.
|
||||||
def generate_zonefile(domain : String) : IPC::JSON
|
def generate_zonefile(domain : String) : IPC::JSON
|
||||||
zone = zone_must_exist! domain
|
generate_zonefile_ domain
|
||||||
|
Response::Success.new
|
||||||
|
end
|
||||||
|
|
||||||
Baguette::Log.info "writing zone file #{@zonefiledir}/#{zone.domain}"
|
# Only an admin can access this function.
|
||||||
# TODO: safe write.
|
def generate_all_zonefiles() : IPC::JSON
|
||||||
File.open("#{@zonefiledir}/#{zone.domain}", "w") do |file|
|
Baguette::Log.info "writing all zone files in #{@zonefiledir}/"
|
||||||
zone.to_bind9 file
|
zones.each do |zone|
|
||||||
|
generate_zonefile_ zone.domain
|
||||||
end
|
end
|
||||||
Response::Success.new
|
Response::Success.new
|
||||||
end
|
end
|
||||||
|
@ -195,7 +201,7 @@ class DNSManager::Storage
|
||||||
@domains_by_name.update_or_create domain_name, domain
|
@domains_by_name.update_or_create domain_name, domain
|
||||||
Response::DomainChanged.new domain
|
Response::DomainChanged.new domain
|
||||||
else
|
else
|
||||||
Response::Error.new "You are't the only owner."
|
Response::Error.new "You are not the only owner."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
1
src/storage/userid.cr
Normal file
1
src/storage/userid.cr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
alias UserDataID = UInt32
|
Loading…
Add table
Reference in a new issue