Reboot script can now power all systems down.
This commit is contained in:
parent
6f56ffa0cd
commit
a88f4af5ce
1 changed files with 23 additions and 9 deletions
|
@ -2,26 +2,40 @@
|
|||
|
||||
|
||||
function rebootMachine() {
|
||||
local machine=$1
|
||||
if (( ${machine} < 10 )); then
|
||||
machine="0${machine}"
|
||||
local MACHINE=$1
|
||||
local HOW=$2
|
||||
if (( ${MACHINE} < 10 )); then
|
||||
MACHINE="0${MACHINE}"
|
||||
fi
|
||||
machine="chrome${machine}.duensing.digital"
|
||||
echo "Attempting reboot of ${machine}..."
|
||||
sshpass -p password ssh -o "StrictHostKeyChecking=no" user@${machine} "sudo reboot"
|
||||
MACHINE="chrome${MACHINE}.duensing.digital"
|
||||
echo "Attempting reboot of ${MACHINE}..."
|
||||
sshpass -p password ssh -o "StrictHostKeyChecking=no" user@${MACHINE} "sudo ${HOW}"
|
||||
}
|
||||
|
||||
|
||||
# Install needed packages.
|
||||
which -s sshpass
|
||||
if [[ $? -eq 1 ]]; then
|
||||
sudo apt-get install -y sshpass
|
||||
fi
|
||||
|
||||
|
||||
# Figure out what to do.
|
||||
HOW="reboot"
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
for i in {1..13}; do
|
||||
rebootMachine $i
|
||||
echo "$0 [all|#] {shutdown}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$2x" == "shutdownx" ]]; then
|
||||
HOW="poweroff"
|
||||
fi
|
||||
|
||||
if [[ "$1x" == "allx" ]]; then
|
||||
for I in {1..13}; do
|
||||
rebootMachine ${I} ${HOW}
|
||||
done
|
||||
else
|
||||
rebootMachine $1
|
||||
rebootMachine ${1} ${HOW}
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue