From 6671ffd0260991318ea77fcc23f358240afc9670 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zolt=C3=A1n=20Felleg?= Date: Tue, 6 Apr 2021 15:53:24 +0200 Subject: [PATCH] Updated vhost{1, 2}.in (added shutdown commands to temperature.sh script). --- sources/vhost1.in/root/temperature.sh | 26 +++++++++++++++++++++----- sources/vhost2.in/root/temperature.sh | 26 +++++++++++++++++++++----- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/sources/vhost1.in/root/temperature.sh b/sources/vhost1.in/root/temperature.sh index e0fa5f2..b4e99d9 100755 --- a/sources/vhost1.in/root/temperature.sh +++ b/sources/vhost1.in/root/temperature.sh @@ -5,6 +5,7 @@ SCRIPT_PATH=$(dirname $(realpath $0)) SCRIPT_BASE=$(basename $(realpath $0) .sh) SCRIPT_CONFIG=$SCRIPT_PATH/${SCRIPT_BASE}.cfg SCRIPT_STOP=$SCRIPT_PATH/${SCRIPT_BASE}.stop +SSH_KEYS_PATH=$SCRIPT_PATH/user-ssh source $SCRIPT_CONFIG @@ -243,7 +244,25 @@ send_sms() { } shutdown_hosts() { - echo "shutting down hosts" + SEVERITY=$1 + + echo "shutting down hosts at $SEVERITY" + if [ $SEVERITY -le 1 ] + then + echo "shutting down store.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 store.in.useribm.hu poweroff + echo "shutting down tsm.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 tsm.in.useribm.hu poweroff + fi + if [ $SEVERITY -gt 1 ] + then + echo "shutting down aiac922.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 aiac922.in.useribm.hu poweroff + echo "shutting down store.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 store.in.useribm.hu poweroff + echo "shutting down tsm.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 tsm.in.useribm.hu poweroff + fi } @@ -319,12 +338,9 @@ fi if [ $SEVERITY -gt 0 ] then + shutdown_hosts $SEVERITY send_sms $MESSAGE_TYPE $TEMPERATURE fi -if [ $SEVERITY -gt 1 ] -then - shutdown_hosts -fi delete_logs delete_mail process_received_smses diff --git a/sources/vhost2.in/root/temperature.sh b/sources/vhost2.in/root/temperature.sh index e0fa5f2..b4e99d9 100755 --- a/sources/vhost2.in/root/temperature.sh +++ b/sources/vhost2.in/root/temperature.sh @@ -5,6 +5,7 @@ SCRIPT_PATH=$(dirname $(realpath $0)) SCRIPT_BASE=$(basename $(realpath $0) .sh) SCRIPT_CONFIG=$SCRIPT_PATH/${SCRIPT_BASE}.cfg SCRIPT_STOP=$SCRIPT_PATH/${SCRIPT_BASE}.stop +SSH_KEYS_PATH=$SCRIPT_PATH/user-ssh source $SCRIPT_CONFIG @@ -243,7 +244,25 @@ send_sms() { } shutdown_hosts() { - echo "shutting down hosts" + SEVERITY=$1 + + echo "shutting down hosts at $SEVERITY" + if [ $SEVERITY -le 1 ] + then + echo "shutting down store.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 store.in.useribm.hu poweroff + echo "shutting down tsm.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 tsm.in.useribm.hu poweroff + fi + if [ $SEVERITY -gt 1 ] + then + echo "shutting down aiac922.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 aiac922.in.useribm.hu poweroff + echo "shutting down store.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 store.in.useribm.hu poweroff + echo "shutting down tsm.in.useribm.hu" + ssh -i $SSH_KEYS_PATH/scripts -l root -o ConnectTimeout=1 tsm.in.useribm.hu poweroff + fi } @@ -319,12 +338,9 @@ fi if [ $SEVERITY -gt 0 ] then + shutdown_hosts $SEVERITY send_sms $MESSAGE_TYPE $TEMPERATURE fi -if [ $SEVERITY -gt 1 ] -then - shutdown_hosts -fi delete_logs delete_mail process_received_smses -- 2.54.0