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