#!/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" ]] { global CLUSTERNAME := $1 } if [[ ! -f "cluster.txt" ]] { "Error: cluster.txt not found" exit } echo -e "" echo -e "\nCluster $CLUSTERNAME members" echo -e "" echo -e "\n

Cluster $CLUSTERNAME members

\n
" echo -e "" while read HOSTNAME MACADDR IPADDR ILOIPADDR DOMAIN ROLE { if [[ "$ROLE" = "head" ]] { global COLOR := 'red' } elif [[ "$ROLE" = "bootstrap" ]] { global COLOR := 'purple' } else { global COLOR := 'black' } echo -e "" echo -e "" echo -e "" echo -e "" echo -e "" echo -e "" } < cluster.txt echo -e "
$HOSTNAMEhostilo" echo -e "" echo -e $ROLE echo -e "" echo -e "
" echo -e "" echo -e "" (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child: (BoolUnary op_id:BoolUnary_z child:{(DQ ($ VSub_Number "$1"))}) ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLUSTERNAME) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [69] ) ] spids: [69] ) ] spids: [-1 66] ) ] spids: [-1 74] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child:(BoolUnary op_id:BoolUnary_f child:{(DQ (cluster.txt))})) ) terminator: ) ] action: [(C {(DQ ("Error: cluster.txt not found"))}) (C {(exit)})] spids: [-1 91] ) ] spids: [-1 101] ) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} { (DQ ("") (EscapedLiteralPart token:) ("Cluster ") ($ VSub_Name "$CLUSTERNAME") (" members") ) } ) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} { (DQ ("") (EscapedLiteralPart token:) ("

Cluster ") ($ VSub_Name "$CLUSTERNAME") (" members

") (EscapedLiteralPart token:) ("
") ) } ) (C {(echo)} {(-e)} { (DQ (") (1) (EscapedLiteralPart token:) (">") ) } ) (While cond: [ (Sentence child: (C {(read)} {(HOSTNAME)} {(MACADDR)} {(IPADDR)} {(ILOIPADDR)} {(DOMAIN)} {(ROLE)}) terminator: ) ] body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobEqual left: {(DQ ($ VSub_Name "$ROLE"))} right: {(DQ (head))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:COLOR) op:Equal rhs:{(red)} spids:[197])] spids: [197] ) ] spids: [-1 194] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobEqual left: {(DQ ($ VSub_Name "$ROLE"))} right: {(DQ (bootstrap))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COLOR) op: Equal rhs: {(purple)} spids: [221] ) ] spids: [221] ) ] spids: [201 218] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:COLOR) op:Equal rhs:{(black)} spids:[228])] spids: [228] ) ] spids: [225 232] ) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} { (DQ ("") ) } ) (C {(echo)} {(-e)} { (DQ ("") ) } ) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} {(DQ (""))}) ] spids: [174 338] ) redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{(cluster.txt)} spids:[340])] ) (C {(echo)} {(-e)} {(DQ ("
") ($ VSub_Name "$HOSTNAME") (") ("https://") ($ VSub_Name "$IPADDR") (EscapedLiteralPart token:) (">host) ("https://") ($ VSub_Name "$ILOIPADDR") (EscapedLiteralPart token:) (">ilo"))}) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} {(DQ ($ VSub_Name "$ROLE"))}) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} {(DQ ("
"))}) (C {(echo)} {(-e)} {(DQ (""))}) (C {(echo)} {(-e)} {(DQ (""))}) ] )