source: ProjectBuilder/projects/proliantusbkey/devel/mkusbkey.sh@ 1331

Last change on this file since 1331 was 1331, checked in by Bruno Cornec, 13 years ago

Adds a new proliantusbkey project

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/bin/sh
2#
3# Make USB key to save/restore HW configuration on a ProLiant DL 680 G7
4#
5#set -x
6
7sync
8DRIVE=$1
9[ -z $DRIVE ] && echo "Usage: $0 device." && exit -1
10[ ! -b $DRIVE ] && echo "$1 is not a block device. Exiting." && exit -1
11KPARTX=`which kpartx`
12[ $? -ne 0 ] && echo "kpartx is missing. exiting" && exit -1
13SYSLINUX=`which syslinux`
14[ $? -ne 0 ] && echo "syslinux is missing. exiting" && exit -1
15
16
17[[ $DRIVE == /dev/sda* ]] && echo "For security, the script does not work on /dev/sda* devices" && exit -1
18
19[[ `cat /proc/mounts | grep $DRIVE` != "" ]] && echo "$DRIVE is mounted. Exit now." && exit -1
20
21# Wipe the partition table.
22dd if=/dev/zero of=$DRIVE bs=4096 count=1 2>&1 > /dev/null
23[ $? -ne 0 ] && echo "WARNING: Unable to erase MBR on $DRIVE."
24
25# Create partition
26echo "Creating the partition on $DRIVE"
27sfdisk -q -D $DRIVE << EOF
280,,C,*
29EOF
30[ $? -ne 0 ] && echo "Unable to partition the key $DRIVE. Exiting" && exit -1
31sfdisk -q -R $DRIVE
32
33if [[ $DRIVE == /dev/loop* ]]; then
34 $KPARTX -av $DRIVE
35 PART="/dev/mapper/${DRIVE#/dev/}p1"
36else
37 PART=${DRIVE}1
38fi
39
40echo "Creating the master boot record on $DRIVE"
41dd if=./mbr.bin of=$DRIVE > 2>&1 /dev/null
42[ $? -ne 0 ] && echo "Unable to copy MBR on $DRIVE. Please check the key. Exiting" && exit -1
43
44# FAT32 filesystem labeled 'LiveUSB'
45sleep 5
46echo "Creating FAT filesystem on $PART"
47mkfs.vfat -n LiveUSB $PART > /dev/null
48[ $? -ne 0 ] && echo "Unable to format the partition $PART as VFAT. Exiting" && exit -1
49
50# The SQUASHFS containing the EXT3 filesystem with the
51# minimum OS and the SSTK tools
52SQUASHFS=$(mktemp -d squashfs.XXXX)
53mkdir $SQUASHFS/LiveOS
54dd if=ext3fs.img of=$SQUASHFS/LiveOS/ext3fs.img 2>&1 > /dev/null
55[ $? -ne 0 ] && echo "Unable to copy the squashfs FS. Exiting" && exit -1
56
57TMPDIR=`mktemp -d mkusb.XXXX`
58if [ ! -d "$TMPDIR" ]; then
59 echo "$TMPDIR is not a directory. Exiting"
60 exit -1
61else
62 if [[ "$TMPDIR" == "/" ]]; then
63 echo "$TMPDIR is /. Exiting"
64 exit -1
65 fi
66fi
67
68ret=0
69mount $PART $TMPDIR
70if [ $? -ne 0 ] ; then
71 echo "Unable to mount $PART under $TMPDIR. Exiting"
72 ret=1
73else
74 mkdir $TMPDIR/syslinux $TMPDIR/LiveOS $TMPDIR/data_files $TMPDIR/fw_files $TMPDIR/log
75 cat > $TMPDIR/fw_files/README << EOF
76ProLIant Linux entry point:
77http://www.hp.com/go/proliantlinux
78
79Firmware update for the DL 380 G7 are available at
80http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=4091432&prodTypeId=15351&prodSeriesId=4091412&swLang=8&taskId=135&swEnvOID=4103
81
82Need to download the various .scexe files and place them in that directory so the server is being updated when choosing the fw option in boot menu.
83
84Latest FW available at time of USB Key built:
85BIOS P67 2011.05.05 (CP015473.scexe)
86iLO3 1.20 2011-04-05 (CP014002.scexe)
87Smart Array 5.06 2011-08-16 (CP015807.scexe)
88Embedded Broadcom NIC 2.3.0 2011-02-24 (CP014348.scexe)
89NC364T NIC - None available
90NC365T NIC - None available
91EOF
92 echo "Copying system files..."
93 $SYSLINUX -i -d syslinux $PART
94 if [ $? -ne 0 ]; then
95 echo "Unable to syslinux $PART. Exiting"
96 ret=1
97 else
98 cp vmlinuz initramfs.img syslinux.cfg $TMPDIR/syslinux
99 cp fw_files/* $TMPDIR/fw_files
100 cp data_files/* $TMPDIR/data_files
101 mksquashfs $SQUASHFS $TMPDIR/LiveOS/squashfs.img
102 if [ $? -ne 0 ]; then
103 echo "Unable to recreate the squash FS $SQUASHFS. Exiting"
104 ret=1
105 fi
106 fi
107fi
108rm -rf $SQUASHFS
109if [ $ret -eq 1 ]; then
110 umount $TMPDIR
111 exit $ret
112fi
113
114echo "Done"
115
116echo "Unmounting file system. It may take some time to flush the buffers..."
117umount $TMPDIR
118
119[[ $PART == "/dev/mapper/loop*" ]] && $KPARTX -dv $DRIVE
120
121rm -rf $TMPDIR
Note: See TracBrowser for help on using the repository browser.