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() {
|
function rebootMachine() {
|
||||||
local machine=$1
|
local MACHINE=$1
|
||||||
if (( ${machine} < 10 )); then
|
local HOW=$2
|
||||||
machine="0${machine}"
|
if (( ${MACHINE} < 10 )); then
|
||||||
|
MACHINE="0${MACHINE}"
|
||||||
fi
|
fi
|
||||||
machine="chrome${machine}.duensing.digital"
|
MACHINE="chrome${MACHINE}.duensing.digital"
|
||||||
echo "Attempting reboot of ${machine}..."
|
echo "Attempting reboot of ${MACHINE}..."
|
||||||
sshpass -p password ssh -o "StrictHostKeyChecking=no" user@${machine} "sudo reboot"
|
sshpass -p password ssh -o "StrictHostKeyChecking=no" user@${MACHINE} "sudo ${HOW}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Install needed packages.
|
||||||
which -s sshpass
|
which -s sshpass
|
||||||
if [[ $? -eq 1 ]]; then
|
if [[ $? -eq 1 ]]; then
|
||||||
sudo apt-get install -y sshpass
|
sudo apt-get install -y sshpass
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Figure out what to do.
|
||||||
|
HOW="reboot"
|
||||||
|
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
for i in {1..13}; do
|
echo "$0 [all|#] {shutdown}"
|
||||||
rebootMachine $i
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$2x" == "shutdownx" ]]; then
|
||||||
|
HOW="poweroff"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1x" == "allx" ]]; then
|
||||||
|
for I in {1..13}; do
|
||||||
|
rebootMachine ${I} ${HOW}
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
rebootMachine $1
|
rebootMachine ${1} ${HOW}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue