Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / cluster / bin / create_slave_tarball.sh
CommitLineData
4e802319 1#!/bin/bash
2
3# ============================================================================
4# Copyright (C) THALES. All rights reserved
5# Author: Laurent Mazet
6# Date : 02/05/2014
7# ============================================================================
8
9# TODO
10# *
11
12PROGNAME=$(basename $0)
13BLADES="slave"
14CLUSTER=/opt/cluster
15EXCLUDE=/tmp/$PROGNAME-exclude-$$
16TFTP=/opt/tftp
17TMPLOG=/tmp/$PROGNAME-$$.log
18VER=1.0
19
20# help function
21
22function usage () {
23 echo "usage: $PROGNAME [-h] [-v]"
24 echo " -h: help message"
25 echo " -v: version message"
26 exit $@
27}
28
29# formating functions
30
31function title () { echo -e "\033[0;1m$*\033[0;0m"; }
32function pass () { echo -e "\033[1;32m$*\033[0;0m"; }
33function warn () { echo -e "\033[1;33m$*\033[0;0m"; }
34function fail () { echo -e "\033[1;31m$*\033[0;0m"; }
35# check command
36
37function check () {
38 echo -n "$@: "
39 { eval $@; } >&$TMPLOG && pass OK || { fail KO; cat $TMPLOG; ERR=yes; }
40 rm -f $TMPLOG
41 test ! "$TEST" = yes
42}
43
44# argument processing
45
46while [ $# -gt 0 ]; do
47 case "$1" in
48 -h) usage 0;;
49 -v) echo "$PROGNAME: version $VER"; exit;;
50 *) echo "unknown argument ($1)"; exit 1;;
51 esac
52 shift
53done
54
55# create exclude list
56cat - <<EOF > $EXCLUDE
57*~
58*.bak
59.*.swp
60.#*
61EOF
62
63# create tarballs
64_OLDPWD=$(pwd)
65for target in $BLADES; do
66 tarball=$TFTP/$target.tgz
67 repository=$CLUSTER/$target
68 [ -d "$repository" ] || { warn "directory '$repository' does not exist"; continue; }
69 [ -f $tarball ] && check rm -f $tarball
70 cd $repository
71 check tar czf $tarball --exclude-from $EXCLUDE .
72done
73cd $_OLDPWD
74
75# clean exclude list
76check rm -f $EXCLUDE
77exit 0