forked from bloomberg/chef-bach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster-to-html.sh
executable file
·51 lines (51 loc) · 1.47 KB
/
cluster-to-html.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#
# Helper to make a web page with links to hosts and their consoles
# (ILOs). Pass the name of the cluster as an optional parameter to
# customise the page title.
#
# At present this is mainly to make it easier to navigate to the ILO
# console of a machine based on its hostname instead of cutting and
# pasting. The host link is not currently useful. This will be
# expanded to emit more useful host links at some point.
#
# This script expects a file cluster.txt to exist and have the format:
# HOSTNAME MACADDRESS IPADDR ILOIPADDR DOMAIN ROLE
#
# Usage : ./cluster-to-html.sh MYCLUSTER > mycluster.html
#
#
if [[ ! -z "$1" ]]; then
CLUSTERNAME="$1"
fi
if [[ ! -f "cluster.txt" ]]; then
"Error: cluster.txt not found"
exit
fi
echo -e "<html>"
echo -e "<head>\n<title>Cluster $CLUSTERNAME members</title></head>"
echo -e "<body>"
echo -e "<font color=slategray>\n<h2>Cluster $CLUSTERNAME members</h2>\n</font>"
echo -e "<table border=\"1\">"
while read HOSTNAME MACADDR IPADDR ILOIPADDR PROFILE DOMAIN ROLE; do
if [[ "$ROLE" = "head" ]]; then
COLOR=red
elif [[ "$ROLE" = "bootstrap" ]]; then
COLOR=purple
else
COLOR=black
fi
echo -e "<tr>"
echo -e "<td>$HOSTNAME</td>"
echo -e "<td><a href=\"https://$IPADDR\">host</a></td>"
echo -e "<td><a href=\"https://$ILOIPADDR\">ilo</a></td>"
echo -e "<td>"
echo -e "<font color=$COLOR>"
echo -e "$ROLE"
echo -e "</font>"
echo -e "</td>"
echo -e "</tr>"
done < cluster.txt
echo -e "</table>"
echo -e "</body>"
echo -e "</html>"