Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / cluster / bin / create_bios_tarball.sh
CommitLineData
4e802319 1#!/bin/bash
2
3# ============================================================================
4# Copyright (C) THALES. All rights reserved
5# Author: Laurent Mazet
6# Date : 09/05/2014
7# ============================================================================
8
9# TODO
10# *
11
12PROGNAME=$(basename $0)
13BIOS=/opt/bios
14EXCLUDE=/tmp/$PROGNAME-exclude-$$
15TFTP=/opt/tftp
16TARBALL=$TFTP/bios.tgz
17TMPROOT=/tmp/$PROGNAME-root-$$
18TMPLOG=/tmp/$PROGNAME-$$.log
19VER=1.0
20
21# help function
22
23function usage () {
24 echo "usage: $PROGNAME [-h] [-v]"
25 echo " -h: help message"
26 echo " -v: version message"
27 exit $@
28}
29
30# formating functions
31
32function title () { echo -e "\033[0;1m$*\033[0;0m"; }
33function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
34function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
35function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
36# check command
37
38function check () {
39 echo -n "$@: "
40 { eval $@; } >&$TMPLOG && pass OK || { fail KO; cat $TMPLOG; ERR=yes; }
41 rm -f $TMPLOG
42 test ! "$TEST" = yes
43}
44
45# argument processing
46
47while [ $# -gt 0 ]; do
48 case "$1" in
49 -h) usage 0;;
50 -v) echo "$PROGNAME: version $VER"; exit;;
51 *) echo "unknown argument ($1)"; exit 1;;
52 esac
53 shift
54done
55
56# create exclude list
57cat - <<EOF > $EXCLUDE
58*~
59*.bak
60.*.swp
61.#*
62EOF
63
64# create repository
65check mkdir $TMPROOT
66for f in $BIOS/*; do
67 check cp $f $TMPROOT
68done
69
70cat > $TMPROOT/+init <<EOF
71#!/bin/sh
72mydir=\$(dirname \$0)
73\$mydir/update_bios_cfg.sh -Y -y
74sleep 10
75reboot -f
76EOF
77chmod +x $TMPROOT/+init
78check test -x $TMPROOT/+init
79
80# create tarball
81_OLDPWD=$(pwd)
82[ -f $TARBALL ] && check rm -f $TARBALL
83cd $TMPROOT
84check tar czf $TARBALL --exclude-from $EXCLUDE .
85cd $_OLDPWD
86
87# clean repository
88check rm -rf $TMPROOT
89
90# clean exclude list
91check rm -f $EXCLUDE
92exit 0