Add Multish script
This commit is contained in:
parent
75a31b6912
commit
b41e73fb35
22
multissh/multish.sh
Executable file
22
multissh/multish.sh
Executable file
@ -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
|
8
multissh/pssh_hosts
Normal file
8
multissh/pssh_hosts
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user