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

@ -35,13 +35,13 @@ need to give Symbiosis your DNS password. To do this, put it in a file called
'mbpassword' in the /srv/my-brilliant-site.com/config/dns/ directory.
As root, run 'symbiosis-dns-generate --verbose --force' to regenerate the DNS
records. These will be under
/srv/my-brilliant-site.com/config/dns/my-brillant-site.com.txt as usual, but
no longer in TinyDNS format.
records. These will be under
/srv/my-brilliant-site.com/config/dns/my-brillant-site.com.txt as usual, but no
longer in TinyDNS format.
Again, as root, run 'symbiosis-dns-mythic -v -f' to force an upload to the DNS
API in verbose mode. This will tell you if you have any template or auth
problems.
Again, as root, run 'symbiosis-dns-mythic --verbose --force' to force an upload
to the DNS API in verbose mode. This will tell you if you have any template or
auth problems.
These operations will be run automatically from cron in future, after any
changes.
@ -53,3 +53,9 @@ TODO
* Detect presence of NS records and skip them if the Mythic DNS template is not 'none'
* Make failures a bit more transparent.
* Clean up some of the spurious template warnings.
Packaging
---------
* dch to update changlog.
* debuild -us -uc
* dh_clean to tidy up.

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
symbiosis-dns-mythic (0.11) stable; urgency=medium
* Switch to long --verbose and --force flags for consistency
-- Ben Charlton <ben@spod.cx> Sat, 27 Apr 2019 15:57:00 +0100
symbiosis-dns-mythic (0.1) stable; urgency=medium
* Initial release.

2
debian/copyright vendored
View file

@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Symbiosis
Source: https://github.com/bcc/symbiosis-dns-mythic
Source: https://gitlab.com/bcc/symbiosis-dns-mythic
Files: *

View file

@ -1 +0,0 @@
symbiosis-dns-mythic

2
debian/files vendored
View file

@ -1,2 +0,0 @@
symbiosis-dns-mythic_0.1_all.deb net extra
symbiosis-dns-mythic_0.1_amd64.buildinfo net extra

View file

@ -1,13 +0,0 @@
#!/bin/sh -e
NAME=symbiosis-dns-mythic
VERSION=$(sed 's/.*(\([^)]*\)).*/\1/;1q' debian/changelog)
n="$NAME-$VERSION"
t="$n.tar.gz"
cd ..
rm -f $t
ln -s ${NAME} $n
tar cfzh $t $n
rm $n
cd ${NAME}

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")

View file

@ -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) = @_;