Add script for OS shutdown on RP

This commit is contained in:
Harry Ho 2021-05-13 10:37:31 +08:00
parent e46781a776
commit ef463c32a5

26
rp_shutdown Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
# RedPitaya hostname and user information
# (The user should have privilege to run `shutdown` - check out `visudo`)
# (Add local SSH key to RP's authorized keys for passwordless login)
export RP_HOST=rp-f0612e
export RP_USER=tester
export RP_KEY=~/.ssh/rp
# Issue shutdown on the RedPitaya
echo "Requesting shutdown on RP at $RP_HOST."
if [[ $RP_KEY == "" ]]
then
ssh $RP_USER@$RP_HOST "sudo shutdown now"
else
ssh -i $RP_KEY $RP_USER@$RP_HOST "sudo shutdown now"
fi
# Check if RedPitaya has been disconnected from network by pinging
while ping $RP_HOST -c 1 >/dev/null 2>/dev/null
do
true
done
# Print time when RedPitaya is down on network
TIMESTAMP_PRETTY=$(date '+%Y-%m-%d %H:%M:%S')
echo "RP disconnected at $TIMESTAMP_PRETTY."