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:
parent
cf6664d4d3
commit
5c24979273
8 changed files with 69 additions and 53 deletions
|
@ -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")
|
||||
|
|
|
@ -2,14 +2,39 @@
|
|||
|
||||
use strict;
|
||||
use WWW::Mechanize;
|
||||
use Getopt::Std;
|
||||
|
||||
our ($opt_v, $opt_f);
|
||||
getopts('vf');
|
||||
use Getopt::Long;
|
||||
|
||||
my $domaindir = "/srv";
|
||||
my $url = 'https://dnsapi.mythic-beasts.com/';
|
||||
|
||||
sub HELP_MESSAGE {
|
||||
print <<EOF;
|
||||
|
||||
Upload symbiosis DNS to Mythic Beasts DNS API.
|
||||
|
||||
Requires the domain API password to be present in /srv/example.com/config/dns/mbpassword
|
||||
|
||||
Flags:
|
||||
|
||||
--verbose Outputs a summary of actions when run.
|
||||
--force Force an upload of the data.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
our ($opt_v, $opt_f, $help);
|
||||
|
||||
GetOptions ("verbose" => \$opt_v,
|
||||
"help" => \$help,
|
||||
"force" => \$opt_f)
|
||||
or die("Error in command line arguments\n");
|
||||
|
||||
if ($help) {
|
||||
HELP_MESSAGE();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
sub upload_dns($$$) {
|
||||
my ($domain, $dnsfile, $password) = @_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue