Statistics
| Branch: | Tag: | Revision:

root / devel / upload @ 24476fa0

History | View | Annotate | Download (3.7 kB)

1 94f3875d Michael Hanselmann
#!/bin/bash
2 6e5e91a1 Guido Trotter
3 68e2ed87 Iustin Pop
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 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 84a12e40 Iustin Pop
# Usage: upload 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 68e2ed87 Iustin Pop
usage() {
31 68e2ed87 Iustin Pop
  echo "Usage: $0 [--no-restart] [--no-cron] [--no-debug] hosts..." >&2
32 68e2ed87 Iustin Pop
  exit $1
33 68e2ed87 Iustin Pop
}
34 68e2ed87 Iustin Pop
35 f9435bdc Iustin Pop
declare -r SED="sed -f autotools/replace_vars.sed"
36 c5159571 Iustin Pop
37 f63eed35 Michael Hanselmann
NO_RESTART=
38 c5159571 Iustin Pop
NO_CRON=
39 747c9ca9 Guido Trotter
NO_DEBUG=
40 f63eed35 Michael Hanselmann
hosts=
41 f63eed35 Michael Hanselmann
while [ "$#" -gt 0 ]; do
42 f63eed35 Michael Hanselmann
  opt="$1"
43 f63eed35 Michael Hanselmann
  case "$opt" in
44 f63eed35 Michael Hanselmann
    --no-restart)
45 f63eed35 Michael Hanselmann
      NO_RESTART=1
46 c5159571 Iustin Pop
      ;;
47 c5159571 Iustin Pop
    --no-cron)
48 c5159571 Iustin Pop
      NO_CRON=1
49 c5159571 Iustin Pop
      ;;
50 747c9ca9 Guido Trotter
    --no-debug)
51 747c9ca9 Guido Trotter
      NO_DEBUG=1
52 747c9ca9 Guido Trotter
      ;;
53 68a5b97a Guido Trotter
    -h|--help)
54 68e2ed87 Iustin Pop
      usage 0
55 68a5b97a Guido Trotter
      ;;
56 f63eed35 Michael Hanselmann
    -*)
57 f63eed35 Michael Hanselmann
      echo "Unknown option: $opt" >&2
58 68e2ed87 Iustin Pop
      usage 1
59 c5159571 Iustin Pop
      ;;
60 f63eed35 Michael Hanselmann
    *)
61 f63eed35 Michael Hanselmann
      hosts="$hosts $opt"
62 c5159571 Iustin Pop
      ;;
63 f63eed35 Michael Hanselmann
  esac
64 f63eed35 Michael Hanselmann
  shift
65 f63eed35 Michael Hanselmann
done
66 f63eed35 Michael Hanselmann
67 68e2ed87 Iustin Pop
if [ -z "$hosts" ]; then
68 68e2ed87 Iustin Pop
  usage 1
69 68e2ed87 Iustin Pop
fi
70 68e2ed87 Iustin Pop
71 f63eed35 Michael Hanselmann
set ${hosts}
72 f63eed35 Michael Hanselmann
73 84a12e40 Iustin Pop
make regen-vcs-version
74 84a12e40 Iustin Pop
75 6e5e91a1 Guido Trotter
TXD=`mktemp -d`
76 6e5e91a1 Guido Trotter
trap 'rm -rf $TXD' EXIT
77 6e5e91a1 Guido Trotter
78 1bc6ab94 Michael Hanselmann
if [[ -f /proc/cpuinfo ]]; then
79 53a9ecb7 Michael Hanselmann
  cpu_count=$(grep -E -c '^processor[[:space:]]*:' /proc/cpuinfo)
80 1bc6ab94 Michael Hanselmann
  make_args=-j$(( cpu_count + 1 ))
81 1bc6ab94 Michael Hanselmann
else
82 1bc6ab94 Michael Hanselmann
  make_args=
83 1bc6ab94 Michael Hanselmann
fi
84 1bc6ab94 Michael Hanselmann
85 0f796800 Bernardo Dal Seno
# Make sure that directories will get correct permissions
86 0f796800 Bernardo Dal Seno
umask 0022
87 0f796800 Bernardo Dal Seno
88 6e5e91a1 Guido Trotter
# install ganeti as a real tree
89 1bc6ab94 Michael Hanselmann
make $make_args install DESTDIR="$TXD"
90 6e5e91a1 Guido Trotter
91 f9435bdc Iustin Pop
# at this point, make has been finished, so the configuration is
92 f9435bdc Iustin Pop
# fixed; we can read the prefix vars/etc.
93 f9435bdc Iustin Pop
PREFIX="$(echo @PREFIX@ | $SED)"
94 f9435bdc Iustin Pop
SYSCONFDIR="$(echo @SYSCONFDIR@ | $SED)"
95 f9435bdc Iustin Pop
PKGLIBDIR="$(echo @PKGLIBDIR@ | $SED)"
96 f9435bdc Iustin Pop
97 c5159571 Iustin Pop
# copy additional needed files
98 ab1a6973 Guido Trotter
[ -f doc/examples/ganeti.initd ] && \
99 c5159571 Iustin Pop
install -D --mode=0755 doc/examples/ganeti.initd \
100 c5159571 Iustin Pop
  "$TXD/$SYSCONFDIR/init.d/ganeti"
101 c5159571 Iustin Pop
102 aa75500a Guido Trotter
[ -f doc/examples/ganeti-master-role.ocf ] && \
103 aa75500a Guido Trotter
install -D --mode=0755 doc/examples/ganeti-master-role.ocf \
104 aa75500a Guido Trotter
  "$TXD/$LIBDIR/ocf/resource.d/ganeti/ganeti-master-role"
105 aa75500a Guido Trotter
106 17071597 Guido Trotter
[ -f doc/examples/ganeti-node-role.ocf ] && \
107 17071597 Guido Trotter
install -D --mode=0755 doc/examples/ganeti-node-role.ocf \
108 17071597 Guido Trotter
  "$TXD/$LIBDIR/ocf/resource.d/ganeti/ganeti-node-role"
109 17071597 Guido Trotter
110 747c9ca9 Guido Trotter
[ -f doc/examples/ganeti.default-debug -a -z "$NO_DEBUG" ] && \
111 752a8ca8 Michael Hanselmann
install -D --mode=0644 doc/examples/ganeti.default-debug \
112 752a8ca8 Michael Hanselmann
  "$TXD/$SYSCONFDIR/default/ganeti"
113 752a8ca8 Michael Hanselmann
114 e80aeb89 Michael Hanselmann
[ -f doc/examples/bash_completion-debug ] && \
115 e80aeb89 Michael Hanselmann
install -D --mode=0644 doc/examples/bash_completion-debug \
116 c5159571 Iustin Pop
  "$TXD/$SYSCONFDIR/bash_completion.d/ganeti"
117 c5159571 Iustin Pop
118 ab1a6973 Guido Trotter
if [ -f doc/examples/ganeti.cron -a -z "$NO_CRON" ]; then
119 c5159571 Iustin Pop
  install -D --mode=0644 doc/examples/ganeti.cron \
120 c5159571 Iustin Pop
    "$TXD/$SYSCONFDIR/cron.d/ganeti"
121 c5159571 Iustin Pop
fi
122 c5159571 Iustin Pop
123 6e5e91a1 Guido Trotter
echo ---
124 6e5e91a1 Guido Trotter
125 6e5e91a1 Guido Trotter
( cd "$TXD" && find; )
126 6e5e91a1 Guido Trotter
127 6e5e91a1 Guido Trotter
echo ---
128 6e5e91a1 Guido Trotter
129 6e5e91a1 Guido Trotter
# and now put it under $prefix on the target node(s)
130 6e5e91a1 Guido Trotter
for host; do
131 6e5e91a1 Guido Trotter
  echo Uploading code to ${host}...
132 b30e35c6 Iustin Pop
  rsync -v -rlDc \
133 b30e35c6 Iustin Pop
    -e "ssh -oBatchMode=yes" \
134 b30e35c6 Iustin Pop
    --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \
135 c5159571 Iustin Pop
    "$TXD/" \
136 c5159571 Iustin Pop
    root@${host}:/ &
137 6e5e91a1 Guido Trotter
done
138 6e5e91a1 Guido Trotter
wait
139 6e5e91a1 Guido Trotter
140 f63eed35 Michael Hanselmann
if test -z "${NO_RESTART}"; then
141 f63eed35 Michael Hanselmann
  for host; do
142 f63eed35 Michael Hanselmann
    echo Restarting ganeti-noded on ${host}...
143 23294fb0 Iustin Pop
    ssh -oBatchMode=yes root@${host} $SYSCONFDIR/init.d/ganeti restart &
144 f63eed35 Michael Hanselmann
  done
145 f63eed35 Michael Hanselmann
  wait
146 f63eed35 Michael Hanselmann
fi