Statistics
| Branch: | Tag: | Revision:

root / devel / upload.in @ 68e2ed87

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