Skip to content

Commit

Permalink
hostname checking script is added due to #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerem Cem ASLAN committed Apr 19, 2018
1 parent b3621f7 commit 5d8e0fb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions check-hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

folder_name=$1
controller_id=${folder_name##*-}
[[ -z $controller_id ]] && { echo "controller id must be present"; exit 3; }
echo "derived controller id: $controller_id"

ssh [email protected] "export controller_id='$controller_id'" '; bash -s ' <<'ENDSSH'
[ $(hostname) == $controller_id ] && exit 0 || exit 6;
ENDSSH


hostname_check=$?
if [[ "$hostname_check" == "6" ]]; then
echo "Target hostname is not $controller_id, aborting!"
exit 7
elif [[ "$hostname_check" == "0" ]]; then
echo "Target hostname is correct."
ssh [email protected]
else
echo "Unknown exit status: $hostname_check"
fi

0 comments on commit 5d8e0fb

Please sign in to comment.