Commit | Line | Data |
---|---|---|
58b0c870 LM |
1 | #!/bin/bash |
2 | ||
3 | # ============================================================================ | |
4 | # Copyright (C) THALES. All rights reserved | |
5 | # Author: Laurent Mazet | |
6 | # Date : 08/12/2014 | |
7 | # ============================================================================ | |
8 | ||
9 | # TODO | |
10 | # * | |
11 | ||
12 | HOST= | |
13 | PROGNAME=$(basename $0) | |
14 | VER=1.0 | |
15 | ||
16 | # help function | |
17 | ||
18 | function usage () { | |
19 | echo "usage: $PROGNAME [-h] [-v] host" | |
20 | echo " -h: help message" | |
21 | echo " -v: version message" | |
22 | exit $@ | |
23 | } | |
24 | ||
25 | # formating functions | |
26 | ||
27 | function title () { echo -e "\033[0;1m$*\033[0;0m"; } | |
28 | function pass () { echo -e "\033[1;32m$*\033[0;0m"; } | |
29 | function warn () { echo -e "\033[1;33m$*\033[0;0m"; } | |
30 | function fail () { echo -e "\033[1;31m$*\033[0;0m"; } | |
31 | ||
32 | # check command | |
33 | ||
34 | function check () { | |
35 | echo -n "$@: " | |
36 | { eval $@; } && pass OK || { fail KO; ERR=yes; } | |
37 | test ! "$TEST" = yes | |
38 | } | |
39 | ||
40 | # argument processing | |
41 | ||
42 | while [ $# -gt 0 ]; do | |
43 | case "$1" in | |
44 | -h) usage 0;; | |
45 | -v) echo "$PROGNAME: version $VER"; exit;; | |
46 | *) HOST=$1;; | |
47 | esac | |
48 | shift | |
49 | done | |
50 | ||
51 | # find master directory | |
52 | mydir=$(dirname $0) | |
53 | mydir=$(cd $mydir; pwd) | |
54 | ||
55 | MASTERREP=$(cd $mydir/../../..; pwd) | |
56 | [ -d $MASTERREP ] || { echo "can't find master repository"; exit 1; } | |
57 | ||
58 | # check host | |
59 | [ "$HOST" ] || { echo "Need a hosname/ip to synchronize master"; exit 1; } | |
60 | ||
61 | # action | |
62 | check chmod g-w -R $MASTERREP | |
63 | check chmod go-rwx $MASTERREP/root/.ssh | |
64 | check chmod go-rwx $MASTERREP/root/.ssh/id_rsa | |
65 | check chmod go-rwx $MASTERREP/opt/cluster/slave/root/.ssh | |
66 | check chmod go-rwx $MASTERREP/opt/cluster/slave/root/.ssh/id_rsa | |
67 | check chmod a+rwx $MASTERREP/opt/tftp | |
68 | check rsync -va --no-o --no-g ~/debian6500/master/ root@$HOST:/ | |
69 | ||
70 | exit 0 |