root / devel / upload.in @ c6286afc
History | View | Annotate | Download (2.4 kB)
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
# Copyright (C) 2006, 2007 Google Inc. |
4 |
# |
5 |
# This program is free software; you can redistribute it and/or modify |
6 |
# it under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 2 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# This program is distributed in the hope that it will be useful, but |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
# General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with this program; if not, write to the Free Software |
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 |
# 02110-1301, USA. |
19 |
|
20 |
# This is a test script to ease development and testing on test clusters. |
21 |
# It should not be used to update production environments. |
22 |
|
23 |
# Usage: upload.sh node-{1,2,3} |
24 |
# it will upload the python libraries to |
25 |
# $prefix/lib/python2.4/site-packages/ganeti and the command line utils to |
26 |
# $prefix/sbin. It needs passwordless root login to the nodes. |
27 |
|
28 |
set -e |
29 |
|
30 |
NO_RESTART= |
31 |
hosts= |
32 |
while [ "$#" -gt 0 ]; do |
33 |
opt="$1" |
34 |
case "$opt" in |
35 |
--no-restart) |
36 |
NO_RESTART=1 |
37 |
;; |
38 |
-h|--help) |
39 |
echo "Usage: $0 [--no-restart] hosts..." |
40 |
exit 0 |
41 |
;; |
42 |
-*) |
43 |
echo "Unknown option: $opt" >&2 |
44 |
exit 1 |
45 |
;; |
46 |
*) |
47 |
hosts="$hosts $opt" |
48 |
;; |
49 |
esac |
50 |
shift |
51 |
done |
52 |
|
53 |
set ${hosts} |
54 |
|
55 |
TXD=`mktemp -d` |
56 |
trap 'rm -rf $TXD' EXIT |
57 |
|
58 |
# install ganeti as a real tree |
59 |
make install DESTDIR="$TXD" |
60 |
|
61 |
echo --- |
62 |
|
63 |
( cd "$TXD" && find; ) |
64 |
|
65 |
echo --- |
66 |
|
67 |
PREFIX='@PREFIX@' |
68 |
|
69 |
# and now put it under $prefix on the target node(s) |
70 |
for host; do |
71 |
echo Uploading code to ${host}... |
72 |
rsync -v -rlDc --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \ |
73 |
"$TXD/$PREFIX/" \ |
74 |
root@${host}:$PREFIX/ & |
75 |
done |
76 |
wait |
77 |
|
78 |
INIT_SCRIPT="$TXD/ganeti.initd" |
79 |
install --mode=0755 doc/examples/ganeti.initd $INIT_SCRIPT |
80 |
for host; do |
81 |
echo Uploading init script to ${host}... |
82 |
scp $INIT_SCRIPT root@${host}:/etc/init.d/ganeti & |
83 |
done |
84 |
wait |
85 |
|
86 |
if [ -f ganeti-master-cron ]; then |
87 |
for host; do |
88 |
echo Uploading cron files to ${host}... |
89 |
scp ganeti-master-cron root@${host}:/etc/ganeti/master-cron & |
90 |
done |
91 |
fi |
92 |
wait |
93 |
|
94 |
if test -z "${NO_RESTART}"; then |
95 |
for host; do |
96 |
echo Restarting ganeti-noded on ${host}... |
97 |
ssh root@${host} /etc/init.d/ganeti restart & |
98 |
done |
99 |
wait |
100 |
fi |