#!/bin/sh # # push-changes # John Simpson 2004-08-25 # # pushes new "data" files to slave tinydns servers using SSH # expects slaves to have the right forced command attached to this key # # Last update: 2020-01-01 jms1 # - Cleaning up for public distribution. # - Using push-targets file instead of hard-coding the server list here. # - Discovering SSH private key filename rather than hard-coding it here. # - Clarified that the license is GPLv2 or GPLv3, but not any unknown future # version of the GPL (I'm not willing to trust a license that I haven't # seen yet.) # ############################################################################### # # Copyright (C) 2004-2020 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 or version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### ######################################## # Read the list of nameservers SERVERS=$( sed 's/#.*$//' push-targets ) if [[ -z "$SERVERS" ]] then echo "ERROR: no remote servers were found in the 'push-targets' file" exit 1 fi ######################################## # Identify the SSH key file keyfiles=( $( ls -1 | grep '^id_' | grep -v '\.pub$' ) ) keycount=${#keyfiles[@]} if [[ $keycount != 1 ]] then echo "ERROR: $keycount id_* files exist, should be 1" exit 1 fi keyfile=${keyfiles[0]} ######################################## # Do the deed for server in $SERVERS do echo "/---- Start of messages from $server" cat data | env - PATH="/usr/bin:/bin" ssh \ -o 'ConnectTimeout 15' -i $keyfile $server zzz \ | sed 's/^/| /' echo "\\---- End of messages from $server" done