-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hostname checking script is added due to #22
- 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.
There are no files selected for viewing
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
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 |