Trying to delete a zone file from a name server (remote) from a local machine (connecting to the remote server with a key pairing).
Script on the name server is below (remzone) which is executable.
#!/bin/bash
sed -i '/$1/,+4d' /etc/named.conf
rm -f /var/named/slaves/$1.db
rndc reload
echo "$1"
The local command I am running is.....
ssh root@server '~/remzone domain.com'
When I run the command locally, the following output is provided.
me@Main:~$ ssh root@server '~/remzone domain.com'
server reload successful
domain.com
When executing the command locally, the domain.com.db is removed from /var/named but it does not remove the matching line (+4 lines) from /etc/named.conf.
Zone "domain.com" IN {
type slave;
masters {XXX.XXX.XXX.XXX;};
file "slaves/domain.com.db";
};
When I run sed -i '/domain.com/,+4d' /etc/named.conf on the nameserver directly, it deletes the zone file correctly from the /etc/named.conf file.
Any Ideas?