Switch to long format --verbose and --force flags

clean up debian packaging

update build docs, minor version bump

Pass --verbose and --force flags to upload script, remove --upload distinction
This commit is contained in:
Ben Charlton 2019-04-27 15:21:18 +01:00
parent cf6664d4d3
commit 5c24979273
8 changed files with 69 additions and 53 deletions

View file

@ -18,7 +18,6 @@
# --template TEMPLATE Specify an alternative template file to read.
#
# --force Force the re-creation of all DNS data.
# --upload Force the upload of all DNS data.
# --help Show the help information for this script.
# --verbose Show debugging information.
#
@ -48,11 +47,6 @@ force = false
help = false
$VERBOSE = false
#
# Do we need to re-upload the data?
#
upload=true
#
# The root directory -- '/' by default.
#
@ -65,7 +59,6 @@ opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--sleep', '-s', GetoptLong::REQUIRED_ARGUMENT ],
[ '--template', '-t', GetoptLong::REQUIRED_ARGUMENT ],
[ '--upload', '-u', GetoptLong::NO_ARGUMENT ],
[ '--verbose', '-v', GetoptLong::NO_ARGUMENT ]
)
@ -83,8 +76,6 @@ opts.each do |opt, arg|
root = arg
when '--force'
force = true
when '--upload'
upload = true
end
end
@ -226,24 +217,28 @@ end
begin
if upload
upload_script = "/usr/sbin/symbiosis-dns-mythic"
verbose "Uploading using #{upload_script}"
IO.popen("#{upload_script} 2>&1","r") do |io|
while !io.eof? do
verbose io.readline
end
end
unless 0 == $?
raise StandardError, "#{upload_script.inspect} failed."
end
else
verbose "No need to upload as no changes in the data have been detected."
upload_script = "/usr/sbin/symbiosis-dns-mythic"
fflag = ""
vflag = ""
if force
fflag = "--force"
end
if $VERBOSE
vflag = "--verbose"
end
verbose "Uploading using #{upload_script}"
IO.popen("#{upload_script} #{fflag} #{vflag} 2>&1","r") do |io|
while !io.eof? do
verbose io.readline
end
end
unless 0 == $?
raise StandardError, "#{upload_script.inspect} failed."
end
rescue StandardError => err
warn "Unable to upload DNS data because #{err.to_s}"
verbose "\t"+err.backtrace.join("\n\t")