diff --git a/README.md b/README.md index 7dbd5d9..9d283de 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/debian/changelog b/debian/changelog index 5f5561d..22002d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +symbiosis-dns-mythic (0.11) stable; urgency=medium + + * Switch to long --verbose and --force flags for consistency + + -- Ben Charlton Sat, 27 Apr 2019 15:57:00 +0100 + symbiosis-dns-mythic (0.1) stable; urgency=medium * Initial release. diff --git a/debian/copyright b/debian/copyright index 503ceef..7e53745 100644 --- a/debian/copyright +++ b/debian/copyright @@ -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: * diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp deleted file mode 100644 index 6fe6fb3..0000000 --- a/debian/debhelper-build-stamp +++ /dev/null @@ -1 +0,0 @@ -symbiosis-dns-mythic diff --git a/debian/files b/debian/files deleted file mode 100644 index cb51ac9..0000000 --- a/debian/files +++ /dev/null @@ -1,2 +0,0 @@ -symbiosis-dns-mythic_0.1_all.deb net extra -symbiosis-dns-mythic_0.1_amd64.buildinfo net extra diff --git a/make-dist b/make-dist deleted file mode 100755 index 9354419..0000000 --- a/make-dist +++ /dev/null @@ -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} diff --git a/sbin/symbiosis-dns-generate b/sbin/symbiosis-dns-generate index 4610590..da80126 100755 --- a/sbin/symbiosis-dns-generate +++ b/sbin/symbiosis-dns-generate @@ -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") diff --git a/sbin/symbiosis-dns-mythic b/sbin/symbiosis-dns-mythic index 004fb6a..f58e5e3 100755 --- a/sbin/symbiosis-dns-mythic +++ b/sbin/symbiosis-dns-mythic @@ -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 < \$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) = @_;