1 | # -*-Shell-script-*-
|
---|
2 | # Common operations to all SSSTK commands
|
---|
3 |
|
---|
4 | # LABEL of the USB key where data will be saved/read
|
---|
5 | USB_KEY_LABEL=LiveUSB
|
---|
6 | ALLBOARDS=/opt/hp/hp-scripting-tools/etc/allboards.xml
|
---|
7 | CONREP_XML=/opt/hp/hp-scripting-tools/etc/conrep.xml
|
---|
8 | LD_LIBRARY_PATH=/opt/hp/hp-scripting-tools/bin:$LD_LIBRARY_PATH
|
---|
9 | IFHW_CMD="/opt/hp/hp-scripting-tools/bin/ifhw"
|
---|
10 |
|
---|
11 | # Create a TMP directory and mount the USB key
|
---|
12 | if [ -z ${TMPDIR} ]; then
|
---|
13 | TMPDIR=$(mktemp -t -d liveusb.XXXXXX)
|
---|
14 | mount -t vfat /dev/disk/by-label/$USB_KEY_LABEL $TMPDIR
|
---|
15 | if [ $? -ne 0 ]; then
|
---|
16 | echo "Unable to mount the USB key"
|
---|
17 | exit 1
|
---|
18 | fi
|
---|
19 | fi
|
---|
20 |
|
---|
21 | # Temporay file listing the HW found
|
---|
22 | if [ -z ${HWDISC_FILE} ]; then
|
---|
23 | HWDISC_FILE="/tmp/hpdiscovery.xml"
|
---|
24 | fi
|
---|
25 |
|
---|
26 | # BIOS information will be saved to/read from this file
|
---|
27 | if [ -z ${BIOS_FILE} ]; then
|
---|
28 | BIOS_FILE="$TMPDIR/data_files/conrep.dat"
|
---|
29 | fi
|
---|
30 |
|
---|
31 | # Smart Array RAID configuration will be saved to/read from this file
|
---|
32 | if [ -z ${RAID_FILE} ]; then
|
---|
33 | RAID_FILE="$TMPDIR/data_files/cpqacuxe.dat"
|
---|
34 | fi
|
---|
35 |
|
---|
36 | # iLO configuration will be saved to/read from this file
|
---|
37 | if [ -z ${ILO_FILE} ]; then
|
---|
38 | ILO_FILE="$TMPDIR/data_files/hponcfg.dat"
|
---|
39 | fi
|
---|
40 |
|
---|
41 | # iLO customization file.
|
---|
42 | # Information will be merged with/substitued to the one present in $ILO_FILE
|
---|
43 | if [ -z ${ILO_CONFIG_FILE} ]; then
|
---|
44 | ILO_CONFIG_FILE="$TMPDIR/config/ilo"
|
---|
45 | fi
|
---|
46 |
|
---|
47 | # Temporary iLO configuration file.
|
---|
48 | # It is the result of the merge/substitution between $ILO_FILE and
|
---|
49 | # $ILO_CONFIG_FILE
|
---|
50 | if [ -z ${ILO_UPDATED_FILE} ]; then
|
---|
51 | ILO_UPDATED_FILE="/tmp/ssstk_hponcfg.dat"
|
---|
52 | fi
|
---|
53 |
|
---|
54 | # This is a very minimal iLO configuration files.
|
---|
55 | # It can be used to restore the iLO interface to a well know state.
|
---|
56 | if [ -z ${ILO_MINIMAL_FILE} ]; then
|
---|
57 | ILO_MINIMAL_FILE="$TMPDIR/data_files/ilo.dat"
|
---|
58 | fi
|
---|
59 |
|
---|
60 | # This time stamp will be added to the log file names before they are copied
|
---|
61 | # to the USB key
|
---|
62 | if [ -z ${TS} ]; then
|
---|
63 | TS=`date +"%Y%m%d-%H%M"`
|
---|
64 | fi
|
---|
65 |
|
---|
66 | PATH=$PATH:/ssstk
|
---|
67 | LD_LIBRARY_PATH=/ssstk
|
---|
68 |
|
---|
69 | # Have to change to that directory otherwise hpdiscovery does not discover
|
---|
70 | # anything
|
---|
71 | cd /ssstk
|
---|
72 |
|
---|
73 | # Loads the drivers and do the pre capture/deploy initialization stuff
|
---|
74 | ssstk_init() {
|
---|
75 | echo ""
|
---|
76 | echo "Loading storage drivers for hardware"
|
---|
77 | load_modules.sh > /dev/null 2>&1
|
---|
78 |
|
---|
79 |
|
---|
80 | echo ""
|
---|
81 | echo "Pausing to allow drivers to finish loading"
|
---|
82 | sleep 15
|
---|
83 | echo ""
|
---|
84 |
|
---|
85 | hp-discovery -f ${HWDISC_FILE} > /dev/null 2>&1
|
---|
86 | echo "Hardware Discovery saved to ${HWDISC_FILE}"
|
---|
87 |
|
---|
88 |
|
---|
89 | export "`hp-hwquery ${HWDISC_FILE} ${ALLBOARDS} SERVERTYPE=SystemName`"
|
---|
90 | export "`hp-hwquery ${HWDISC_FILE} ${ALLBOARDS} BOOTDEVNODE=DevNode`";
|
---|
91 |
|
---|
92 | echo "Server Type: ${SERVERTYPE}"
|
---|
93 |
|
---|
94 | }
|
---|
95 |
|
---|
96 | # Saves the logs to the USB key and umount it
|
---|
97 | ssstk_stop() {
|
---|
98 | echo "Saving logs on USB key"
|
---|
99 | if [ -d "$TMPDIR/log" ]; then
|
---|
100 | for i in /tmp/ssstk_*; do
|
---|
101 | FILE=${i%%.*}
|
---|
102 | EXT=${i##*.}
|
---|
103 | cp $i ${TMPDIR}/log/${FILE##/tmp/ssstk_}-${TS}.${EXT}
|
---|
104 | done
|
---|
105 | fi
|
---|
106 | echo "Unmounting the key"
|
---|
107 | umount $TMPDIR
|
---|
108 | rmdir $TMPDIR
|
---|
109 | }
|
---|