From b41e73fb3593fbc55344608f26001de3415f8924 Mon Sep 17 00:00:00 2001 From: Thomas Cole Date: Wed, 6 Oct 2021 15:50:03 -0400 Subject: [PATCH] Add Multish script --- multissh/multish.sh | 22 ++++++++++++++++++++++ multissh/pssh_hosts | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100755 multissh/multish.sh create mode 100644 multissh/pssh_hosts diff --git a/multissh/multish.sh b/multissh/multish.sh new file mode 100755 index 0000000..d086c99 --- /dev/null +++ b/multissh/multish.sh @@ -0,0 +1,22 @@ +#!/bin/bash +CMD=$1 + +echo -e "You are about to run \e[1;32m$CMD\e[0m on all hosts." + +run () { + if grep -q "sudo" <<< "$CMD"; then + echo "sudo command detected. Attempting to elevate permissions" + parallel-ssh -A -i -x '-tt' -t 0 -h pssh_hosts -l ansible "echo 'ansible' | $CMD && history -c" + else + parallel-ssh -A -i -x '-tt' -h pssh_hosts -l ansible "$CMD && history -c" + fi +} + +while true; do + read -p "Are you sure? (y/n): " yn + case $yn in + [Yy]* ) run; break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done diff --git a/multissh/pssh_hosts b/multissh/pssh_hosts new file mode 100644 index 0000000..7960708 --- /dev/null +++ b/multissh/pssh_hosts @@ -0,0 +1,8 @@ +w150-debian.local +center6-debian.local +library-debian.local +lacky-debian.local +foruma-debian.local +forumb-debian.local +forumc-debian.local +musicroom-debian.local