Last active
November 3, 2017 21:56
-
-
Save fredleger/8d13be5ffe3da4d961e5d32470f10e10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# -------------------------------------------------- | |
# stop a synology nas using ssh and poweroff | |
# -------------------------------------------------- | |
CURRENTDIR=$(dirname $(realpath $0)) | |
HOST=${1:-192.168.77.2} | |
USER=${2:-admin} | |
SSHPRIVATEKEY=${3:-$CURRENTDIR/syno.priv} | |
SSH_EXTRA_ARGS="-q -o StrictHostKeyChecking=no" | |
#CMD="sudo poweroff" | |
CMD="sudo /bin/bash -c 'echo 1 >/dev/ttyS1'" | |
if [ $(ping -c 1 ${HOST} > /dev/null && echo $?) ]; then | |
ssh ${SSH_EXTRA_ARGS} -i ${SSHPRIVATEKEY} ${USER}@${HOST} ${CMD} | |
exit $? | |
else | |
echo "Host is not alive, skipping it..." | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment