Migration script: first draft.
This commit is contained in:
parent
b53b31b584
commit
925a456de7
@ -29,6 +29,7 @@ class Actions
|
|||||||
# Maintenance.
|
# Maintenance.
|
||||||
@the_call["admin-maintenance"] = ->admin_maintenance
|
@the_call["admin-maintenance"] = ->admin_maintenance
|
||||||
@the_call["admin-generate-zonefile"] = ->admin_generate_zonefile
|
@the_call["admin-generate-zonefile"] = ->admin_generate_zonefile
|
||||||
|
@the_call["admin-migration-script"] = ->admin_migration_script
|
||||||
@the_call["admin-generate-all-zonefiles"] = ->admin_generate_all_zonefiles
|
@the_call["admin-generate-all-zonefiles"] = ->admin_generate_all_zonefiles
|
||||||
|
|
||||||
# Domain operations.
|
# Domain operations.
|
||||||
@ -86,6 +87,26 @@ class Actions
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Migration script.
|
||||||
|
#
|
||||||
|
# Usage: dnsmanager-client admin migration-script user-db.txt
|
||||||
|
#
|
||||||
|
# user-db.txt should be formated as: login <TAB> domain1 <TAB> domain2 <TAB> domain3 (etc.)
|
||||||
|
def admin_migration_script
|
||||||
|
filename = Context.args.not_nil!.[0]
|
||||||
|
File.each_line(filename) do |line|
|
||||||
|
data = line.split "\t"
|
||||||
|
login = data.shift
|
||||||
|
begin
|
||||||
|
Baguette::Log.info "migrating login #{login}, domains: #{data.join(',')}"
|
||||||
|
# TODO
|
||||||
|
#pp! @dnsmanagerd.migration
|
||||||
|
rescue e
|
||||||
|
puts "error for generate_zonefile: #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def admin_generate_all_zonefiles
|
def admin_generate_all_zonefiles
|
||||||
pp! @dnsmanagerd.generate_all_zonefiles
|
pp! @dnsmanagerd.generate_all_zonefiles
|
||||||
rescue e
|
rescue e
|
||||||
|
@ -116,6 +116,13 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
|
|||||||
unrecognized_args_to_context_args.call parser, 0, nil
|
unrecognized_args_to_context_args.call parser, 0, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Migration script.
|
||||||
|
parser.on("migration-script", "Migrate domains from dnsmanager v1.") do
|
||||||
|
Baguette::Log.info "migration script, provide domains to users."
|
||||||
|
Context.command = "admin-migration-script"
|
||||||
|
parser.banner = "COMMAND: admin migration-script user-db.txt"
|
||||||
|
unrecognized_args_to_context_args.call parser, 1, nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# User section.
|
# User section.
|
||||||
|
Loading…
Reference in New Issue
Block a user