|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
Appending to file on remote host via SSH
Hey guys! I'm playing around with scripting for (basically) my first time. I found out most of what I needed through examples I found on google and have finished with about the first three-fourths of the script. Essentially, I am creating a script that makes my life easier when adding domains to my DNS servers. In one of our DNS farms we have 5 servers (1 master, not public facing, and 4 slaves which *are* public facing). In any case, creating the initial zone file and then modifying 5 instances of named.conf can get quite tedious when you're adding almost a new domain every day, so I'm trying to come up with a solution.
The script, when complete, will do this: 1) Create an initial zone file in /etc/namedb/master/ 2) Add the zone to named.conf 3) Reload named, to read in the new named.conf 4) via SSH, append the new zone to named.conf on the slaves 5) via rndc, reload the slaves remotely This part all works EXCEPT for #4 above: Code:
if [ -z "$1" ] || [ -z "$2" ] then echo "Proper usage of this script is `basename $0` [domain-name] [IP address]" exit fi #Let's do the zone file ... echo "Creating initial zone file ..." echo "\$TTL 300 $1. IN SOA ns1.pwned.com. hostmaster.pwned.com. ( 2008060401 ; serial 1H ; refresh 10M ; retry 1D ; expire 1D ; minimum ) NS ns1.pwned.com. NS ns2.pwned.com. A $2 www CNAME @ " > /etc/namedb/master/db.$1 echo "Changing ownership on db.$1 ..." chown bind:bind /etc/namedb/master/db.$1 # Let's update named.conf ... echo "Updating named.conf ..." echo zone \"$1\"" { type master; file \"master/db.$1\"; }; " >> /etc/namedb/named.conf # Reload named for changes to take effect ... echo "Reloading named ..." rndc reload Code:
ssh ns2 echo "zone \"test.com\" { type slave; file \"sec/db.test.com\"; masters { 72.26.x.x; }; }; " >> /etc/namedb/named.conf Code:
bash: line 1: type: slave: not found bash: -c: line 3: syntax error near unexpected token `}' bash: -c: line 3: ` masters { 72.26.x.x; }; Thanks. I hope I was clear enough. Last edited by splooge; 7th June 2008 at 02:37 AM. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PHP read file contents - Maximum file size | cksraj | Programming | 1 | 21st September 2009 11:38 AM |
ssh/rdesktop into host behind NAT | JMJ_coder | General software and network | 18 | 13th January 2009 08:19 PM |
Print on remote WinXP from web host | drhowarddrfine | General software and network | 5 | 13th October 2008 05:41 PM |
Remote Access to File Server | Oko | OpenBSD Security | 7 | 23rd June 2008 05:17 PM |
Changing IP to host www, mail and etc in FreeBSSD | neubie | FreeBSD General | 5 | 19th June 2008 07:34 AM |