Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / cluster / bin / create_root_tarball.sh
1 #!/bin/bash
2
3 # ============================================================================
4 # Copyright (C) THALES. All rights reserved
5 # Author: Laurent Mazet
6 # Date : 20/02/2014
7 # ============================================================================
8
9 # TODO
10 # *
11
12 PROGNAME=$(basename $0)
13 TFTP=/opt/tftp
14 EXCLUDE=/tmp/$PROGNAME-exclude-$$
15 IMAGE=$TFTP/root.tgz
16 TMPLOG=/tmp/$PROGNAME-$$.log
17 VER=2.0
18
19 # help function
20
21 function usage () {
22 echo "usage: $PROGNAME [-h] [-v]"
23 echo " -h: help message"
24 echo " -v: version message"
25 exit $@
26 }
27
28 # formating functions
29
30 function title () { echo -e "\033[0;1m$*\033[0;0m"; }
31 function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
32 function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
33 function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
34 # check command
35
36 function check () {
37 echo -n "$@: "
38 { eval $@; } >&$TMPLOG && pass OK || { fail KO; cat $TMPLOG; ERR=yes; }
39 rm -f $TMPLOG
40 test ! "$TEST" = yes
41 }
42
43 # argument processing
44
45 while [ $# -gt 0 ]; do
46 case "$1" in
47 -h) usage 0;;
48 -v) echo "$PROGNAME: version $VER"; exit;;
49 *) echo "unknown argument ($1)"; exit 1;;
50 esac
51 shift
52 done
53
54 # create exclude list
55 cat - <<EOF > $EXCLUDE
56 backup
57 boot
58 dev/*
59 dump
60 etc/.git
61 etc/udev/rules.d/70-persistent-net.rules
62 home
63 lost+found
64 opt/*
65 proc/*
66 root/*
67 run/*
68 sys/*
69 tmp/*
70 trc6500_list_patched_files.txt
71 usr/share/doc
72 usr/share/i18n
73 usr/share/info
74 usr/share/locale
75 usr/share/man
76 usr/share/zoneinfo
77 var/backups/*
78 var/cache/apt/*
79 var/cache/debconf/*
80 var/cache/fontconfig/*
81 var/cache/man/*
82 var/lib/apt
83 var/lib/aptitude
84 var/lib/dpkg
85 var/lib/samba/*
86 var/lock/*
87 var/log/*
88 var/run/*
89 EOF
90 check test -f $EXCLUDE
91
92 # checks
93 [ -f $IMAGE ] && check rm -f $IMAGE
94 _OLDPWD=$(pwd)
95 cd /
96 check tar czf $IMAGE --exclude-from $EXCLUDE .
97 cd $_OLDPWD
98
99 # clean exclude list
100 check rm -f $EXCLUDE
101 exit 0