Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / cluster / bin / create_root_tarball.sh
CommitLineData
4e802319 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
12PROGNAME=$(basename $0)
13TFTP=/opt/tftp
14EXCLUDE=/tmp/$PROGNAME-exclude-$$
15IMAGE=$TFTP/root.tgz
16TMPLOG=/tmp/$PROGNAME-$$.log
17VER=2.0
18
19# help function
20
21function 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
30function title () { echo -e "\033[0;1m$*\033[0;0m"; }
31function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
32function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
33function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
34# check command
35
36function 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
45while [ $# -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
52done
53
54# create exclude list
55cat - <<EOF > $EXCLUDE
56backup
57boot
58dev/*
59dump
60etc/.git
61etc/udev/rules.d/70-persistent-net.rules
62home
63lost+found
64opt/*
65proc/*
66root/*
67run/*
68sys/*
69tmp/*
70trc6500_list_patched_files.txt
71usr/share/doc
72usr/share/i18n
73usr/share/info
74usr/share/locale
75usr/share/man
76usr/share/zoneinfo
77var/backups/*
78var/cache/apt/*
79var/cache/debconf/*
80var/cache/fontconfig/*
81var/cache/man/*
82var/lib/apt
83var/lib/aptitude
84var/lib/dpkg
85var/lib/samba/*
86var/lock/*
87var/log/*
88var/run/*
89EOF
90check test -f $EXCLUDE
91
92# checks
93[ -f $IMAGE ] && check rm -f $IMAGE
94_OLDPWD=$(pwd)
95cd /
96check tar czf $IMAGE --exclude-from $EXCLUDE .
97cd $_OLDPWD
98
99# clean exclude list
100check rm -f $EXCLUDE
101exit 0