From 8ee58135ce721917bc36e569ae2c9b77c041e6c0 Mon Sep 17 00:00:00 2001 From: Jochen Welzel Date: Mon, 18 Jan 2021 17:41:55 +0100 Subject: [PATCH] add error handling and output --- scp_and_reload.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scp_and_reload.sh b/scp_and_reload.sh index e099cf5..9fea095 100644 --- a/scp_and_reload.sh +++ b/scp_and_reload.sh @@ -6,10 +6,25 @@ mkdir .ssh echo $PLUGIN_KEY > .ssh/id_rsa chmod 600 .ssh/id_rsa +echo "Changed files: $CHFILENAMES" + for file in $CHFILENAMES; do if [[ $file == *"zone" ]]; then + echo "SCP of $file started" scp $file "$PLUGIN_USER"@"$PLUGIN_HOSTS":"$PLUGIN_TARGET"/$file + if [ $? -ne 0 ]; then + echo "SCP failed" > &2 + exit 1 + fi ZONE=$(echo $file | sed 's/\.zone//') + echo "Reload $ZONE zone" ssh "PLUGIN_USER"@"$PLUGIN_HOSTS" nsd-control reload $ZONE + if [ $? -ne 0 ]; then + echo "Reload of zone failed" > &2 + exit 1 + fi + else + echo "Nothing to upload" fi done +echo "All done"