That is really fantastic! Not quite what I'm looking for, but that is very cool either way.
Josh Luthman Office: 937-552-2340 Direct: 937-552-2343 1100 Wayne St Suite 1337 Troy, OH 45373 On Sun, May 24, 2015 at 1:25 AM, Cameron Camp <[email protected]> wrote: > I wrote a CLI “wizard” that steps you thought it, use parts of it if you > find useful. It creates a Debian style structure where you can > enable/disable available zones if you want, which makes it easier to > manage. You create a db.example.com example zone, and then the script > copies and modifies it to become a real zone file, so just create what you > want for an example that has all your normal stuff in it. It also runs dig > later to see if it worked. This is just itch/scratch stuff, guaranteed to > do nothing in particular, and certainly not vetted, but very handy. Of > course, if you find it useless/confusing/crap code, ignore it and use > something else. It’s been very handy for us. I just called it newdomain.sh > and put it in /usr/src, then symlinked to it so you can just type > “newdomain”. > > ——— > > #!/bin/bash > > ## get your IP and domain information > # > > cd /usr/src/ > > echo "Enter domain name to create, then hit [Enter]: " > read domain > echo "." > echo "What IP is the www server for this domain? [Enter]: " > read ip > echo "What IP is the MAIL server for this domain? [Enter]: " > read mail > > ## okay, modifying the template file and writing it to the > # /etc/bind/zones/file > > cp /usr/src/db.example.com /etc/bind/zones/db.$domain > > echo "changing the domain name in the example file to $domain" > sed -i -e "s/example.com/$domain/g" /etc/bind/zones/db.$domain > > echo "changing IP's in default file for www..." > sed -i -e "s/1.2.3.4/$ip/g" /etc/bind/zones/db.$domain > sed -i -e "s/5.6.7.8/$mail/g" /etc/bind/zones/db.$domain > > echo "." > echo "ok, your config file now looks like this...look sane?" > > cat /etc/bind/zones/db.$domain > > echo "." > echo "now creating the zone include file in /etc/bind/zones.enabled" > > ## now building the zone link file and putting it in > # /etc/bind/zones.enabled so we can can enable it later > > cp /usr/src/zoneinclude /etc/bind/zones.enabled/zone.$domain > > sed -i -e "s/example.com/$domain/g" /etc/bind/zones.enabled/zone.$domain > > echo "" > echo "now linking the domain so bind will see it" > > ## link new domain into /etc/bind/named.conf.local so it will load > > echo 'include "/etc/bind/zones.enabled/zone.'$domain'";' >> > /etc/bind/named.conf.local > > echo "." > echo "if that all worked, you need to reload bind, do you want to try it > now? [y/n]" > read input > case "$input" in > [yY] | [yY][eE][sS]) > echo "Okay, reloading bind9" > /etc/init.d/bind9 reload > ;; > [nN] | [nN][oO]) > echo "You should manually reload bind later" ;; > *) echo "Your input was officially odd '$input'" ;; > esac > > chown -R bind.bind /etc/bind/* > > echo "here's what the zone looks like on the local server now" > dig $domain @localhost > > echo "done..." > > — > > > > > > > >
