-
Notifications
You must be signed in to change notification settings - Fork 1
/
enlighten.sh
executable file
·133 lines (108 loc) · 2.66 KB
/
enlighten.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# enlighten.sh
#
# A clustered Samba hacking script to synchronize the code repositories on the
# cluster nodes.
DEFAULT_NODES="ganesh buddhi riddhi siddhi"
get_help() {
echo "USAGE: enlighten.sh [-bcf] [<node> ...]
A clustered Samba hacking script to synchronize the code repositories on the
cluster nodes. By default, this script only tries to update the code on remote
nodes via rsync. Nodes are specified as a space-separated list of names or IP
address. If no nodes are specified, the following list is used:
$DEFAULT_NODES
Options:
-b, --build
Run a Samba build on the first node before distributing the repo to the
other nodes.
-c, --configure
Clean the repo, run configure, and do a Samba build. Implies --build.
-f, --force
Normally, this script attempts to synchronize the repositories using an
rsync batched write. This can be really finnicky if you change anything
on the remote repositories. Use --force to perform a full, non-batched
rsync on every node. This is much slower but will usually succeed.
"
}
BUILD=false
FORCE=false
CMD="make -j4"
while [[ $# > 0 ]]; do
ARG="$1"
if [[ ${ARG:0:1} != "-" ]]; then
break
fi
OPTS=()
if [[ ${#ARG} -gt 2 && ${ARG:0:2} != "--" && ${ARG:0:1} == "-" ]]; then
for (( i=1; i<${#ARG}; i++ )); do
OPTS+=("-${ARG:$i:1}")
done
else
OPTS+=($ARG)
fi
for OPT in "${OPTS[@]}"; do
case $OPT in
-b|--build)
BUILD=true
shift
;;
-f|--force)
FORCE=true
shift
;;
-c|--configure)
BUILD=true
CMD="./wafbuild.sh"
shift
;;
*)
echo "Unknown option: $OPT"
get_help
exit
;;
esac
done
done
nodes=${@:-"$DEFAULT_NODES"}
echo "BUILD: $BUILD"
echo "FORCE: $FORCE"
echo "CMD..: $CMD"
echo "NODES: $nodes"
exit
rm -rf rsync-batch*; rm -rf ../samba-rsync/rsync-batch*
if $FORCE; then
rsync -rltvD . ../samba-rsync >/dev/null
else
rsync --write-batch=rsync-batch -rltvD . ../samba-rsync >/dev/null
fi
sync_repo() {
echo "Syncing $1..."
ssh $1 "rm -rf rsync_batch*; rm -rf samba/rsync-batch* >/dev/null"
if $FORCE; then
rsync -rltvD . $1:samba >/dev/null
else
scp -q rsync-batch* $1:
ssh $1 "./rsync-batch.sh samba >/dev/null"
fi
}
if $BUILD; then
head=$(echo "$nodes" | awk '{ print $1 }')
others=${nodes#$head }
echo "Syncing $head..."
sync_repo $head
echo "Running command [$CMD] on $head..."
ssh $head "cd samba; $CMD"
ret=$?
if [ $ret == 0 ]; then
if $FORCE; then
FFLAG="f"
else
FFLAG=""
fi
ssh $head "cd samba; ./enlighten.sh -${FFLAG} ${others}"
fi
else
for n in $nodes; do
sync_repo $n
done
fi