~ubuntu-core-dev/ubuntu/maverick/eucalyptus/devel

« back to all changes in this revision

Viewing changes to .pc/07-local_support_euca_conf-in.patch/tools/euca_upgrade

  • Committer: Dustin Kirkland
  • Date: 2010-07-22 08:41:57 UTC
  • mfrom: (1050.1.19 ubuntu)
  • Revision ID: kirkland@x200-20100722084157-zh2p8dkawznvxxpn
Approving Dave Walker's merge of new upstream Eucalyptus 2.0 release.

Dustin Kirkland <kirkland@canonical.com>

* New major upstream version merge, 2.0 (r1211).
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
#Copyright (c) 2009  Eucalyptus Systems, 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, only version 3 of the License.  
 
8
 
9
#This file is distributed in the hope that it will be useful, but WITHOUT
 
10
#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
#FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
12
#for more details.  
 
13
#
 
14
#You should have received a copy of the GNU General Public License along
 
15
#with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
17
#Please contact Eucalyptus Systems, Inc., 130 Castilian
 
18
#Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/> 
 
19
#if you need additional information or have any questions.
 
20
#
 
21
#This file may incorporate work covered under the following copyright and
 
22
#permission notice:
 
23
#
 
24
#  Software License Agreement (BSD License)
 
25
#
 
26
#  Copyright (c) 2008, Regents of the University of California
 
27
#  
 
28
#
 
29
#  Redistribution and use of this software in source and binary forms, with
 
30
#  or without modification, are permitted provided that the following
 
31
#  conditions are met:
 
32
#
 
33
#    Redistributions of source code must retain the above copyright notice,
 
34
#    this list of conditions and the following disclaimer.
 
35
#
 
36
#    Redistributions in binary form must reproduce the above copyright
 
37
#    notice, this list of conditions and the following disclaimer in the
 
38
#    documentation and/or other materials provided with the distribution.
 
39
#
 
40
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 
41
#  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 
42
#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 
43
#  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 
44
#  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
45
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
46
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
47
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
48
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
49
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
50
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
 
51
#  THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
 
52
#  LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
 
53
#  SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
 
54
#  IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
 
55
#  BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
 
56
#  THE REGENTS’ DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
 
57
#  OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
 
58
#  WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
 
59
#  ANY SUCH LICENSES OR RIGHTS.
 
60
#
 
61
 
 
62
NEW_EUCA=""
 
63
OLD_EUCA=""
 
64
FORCE=""
 
65
OPENSSL="`which openssl 2> /dev/null`"
 
66
DB="N"
 
67
CONF="N"
 
68
KEYS="N"
 
69
 
 
70
usage() {
 
71
        echo "$0 [options]"
 
72
        echo
 
73
        echo "This script attempts to upgrade an old installation of eucalyptus"
 
74
        echo
 
75
        echo "   --help                   this page"
 
76
        echo "   --new <euca_dir>         where the new eucalyptus is installed"
 
77
        echo "   --old <euca_dir>         where the old eucalyptus is installed"
 
78
        echo "   --backup <euca_dir>      create a backup of an existing eucalyptus installation"
 
79
        echo "   --force                  attempt the upgrade even if a database is detected"
 
80
        echo "   --conf                   upgrade the conf file"
 
81
        echo "   --db                     upgrade the database"
 
82
        echo "   --keys                   upgrade the keys"
 
83
        echo
 
84
}
 
85
 
 
86
while [ $# -gt 0 ]; do
 
87
        if [ "$1" = "-h" -o "$1" = "-help" -o "$1" = "?" -o "$1" = "--help" ]; then
 
88
                usage
 
89
                exit 1
 
90
        fi
 
91
        if [ "$1" = "--db" ]; then
 
92
                DB="Y"
 
93
                shift
 
94
                continue
 
95
        fi
 
96
        if [ "$1" = "--conf" ]; then
 
97
                CONF="Y"
 
98
                shift
 
99
                continue
 
100
        fi
 
101
        if [ "$1" = "--keys" ]; then
 
102
                KEYS="Y"
 
103
                shift
 
104
                continue
 
105
        fi
 
106
        if [ "$1" = "--backup" ]; then
 
107
                if [ -z "$2" ]; then
 
108
                        echo "--backup requires eucalyptus directory"
 
109
                        exit
 
110
                fi
 
111
                BACKUP="$2"
 
112
                shift; shift;
 
113
                continue
 
114
        fi
 
115
        if [ "$1" = "--new" ]; then
 
116
                if [ -z "$2" ]; then
 
117
                        echo "--new requires eucalyptus directory"
 
118
                        exit
 
119
                fi
 
120
                NEW_EUCA="$2"
 
121
                shift; shift;
 
122
                continue
 
123
        fi
 
124
        if [ "$1" = "--old" ]; then
 
125
                if [ -z "$2" ]; then
 
126
                        echo "--old requires eucalyptus directory"
 
127
                        exit
 
128
                fi
 
129
                OLD_EUCA="$2"
 
130
                shift; shift;
 
131
                continue
 
132
        fi
 
133
        if [ "$1" == "--force" ]; then
 
134
                FORCE="Y"
 
135
                shift
 
136
                continue
 
137
        fi
 
138
        usage
 
139
        exit 1
 
140
done
 
141
 
 
142
if [ -d "$BACKUP" ]; then
 
143
    # backup useful bits of existing eucalyptus installation
 
144
    echo "Backing up $BACKUP..."
 
145
    CWD=`pwd` 
 
146
    DATESTR=`date +%s`
 
147
    mkdir -p /root/eucalyptus.backup.$DATESTR
 
148
    cd /root/eucalyptus.backup.$DATESTR
 
149
    echo "Backing up to /root/eucalyptus.backup.$DATESTR"
 
150
    EUCABACKUPS=""
 
151
    for i in $EUCADIR/var/lib/eucalyptus/keys/ $EUCADIR/var/lib/eucalyptus/db/ $EUCADIR/etc/eucalyptus/eucalyptus.conf $EUCADIR/etc/eucalyptus/eucalyptus-version
 
152
    do
 
153
        if [ -e $i ]; then
 
154
            echo "Adding $i"
 
155
            EUCABACKUPS="$EUCABACKUPS $i"
 
156
        fi
 
157
    done
 
158
    tar cf - $EUCABACKUPS 2>/dev/null | tar xf - 2>/dev/null
 
159
    cd $CWD
 
160
    echo "Done."
 
161
    exit 0
 
162
fi
 
163
 
 
164
# default NEW install and some checks
 
165
if [ -z "$NEW_EUCA" ]; then
 
166
        echo "Use --new to specify the location of the new installation"
 
167
        exit 1
 
168
fi 
 
169
if [ -z "$OLD_EUCA" ]; then
 
170
        echo "Use --old to specify the old installation from which we upgrade"
 
171
        exit 1
 
172
fi
 
173
if [ ! -e $NEW_EUCA/etc/eucalyptus/eucalyptus-version ]; then
 
174
        echo "cannot locate $NEW_EUCA/etc/eucalyptus/eucalyptus-version, --new must point to a valid eucalyptus installation"
 
175
        exit 1;
 
176
else
 
177
    new_euca_version="`cat $NEW_EUCA/etc/eucalyptus/eucalyptus-version 2> /dev/null`"
 
178
fi
 
179
if [ ! -e $OLD_EUCA/etc/eucalyptus/eucalyptus-version ]; then
 
180
        echo "Cannot locate $OLD_EUCA/etc/eucalyptus/eucalyptus-version, --old must point to a valid eucalyptus installation/backup.  If this is a valid installation and the version file is missing, please create one with the version of eucalyptus you are upgrading from (i.e. '1.6.1')"
 
181
        exit 1;
 
182
else
 
183
    old_euca_version="`cat $OLD_EUCA/etc/eucalyptus/eucalyptus-version 2> /dev/null`"
 
184
fi
 
185
 
 
186
NEW_EUCA_VER_NUM=`echo $new_euca_version | sed "s/\.//g"`
 
187
OLD_EUCA_VER_NUM=`echo $old_euca_version | sed "s/\.//g"`
 
188
 
 
189
# valid version upgrade check
 
190
if [ $new_euca_version = $old_euca_version ]; then
 
191
    SAMEVER="Y"
 
192
else 
 
193
    SAMEVER="N"
 
194
fi
 
195
 
 
196
if [ $new_euca_version = "1.6.2" ]; then
 
197
    if [ $old_euca_version != "1.6.1" ]; then
 
198
        echo "Cannot upgrade from $old_euca_version to $new_euca_version, skipping automatic upgrade"
 
199
        exit 0
 
200
    fi
 
201
fi
 
202
 
 
203
echo "Upgrading from version $old_euca_version ($OLD_EUCA_VER_NUM) to $new_euca_version ($NEW_EUCA_VER_NUM)"
 
204
#if [ `expr $euca_version "<" 1.6` -eq 1 ]; then
 
205
#       echo "$NEW_EUCA is not a 1.6.x Eucalyptus installation"
 
206
#       exit 2
 
207
#fi
 
208
 
 
209
# upgrade conf file
 
210
if [ "$CONF" = "Y" ]; then
 
211
    echo "Upgrading configuration file..."
 
212
    if [ "$SAMEVER" = "Y" ]; then
 
213
        cp --preserve -a $OLD_EUCA/etc/eucalyptus/eucalyptus.conf $NEW_EUCA/etc/eucalyptus/eucalyptus.conf
 
214
        echo "Done."
 
215
    else
 
216
        
 
217
    # we need euca_conf later (the new version)
 
218
        if [ ! -x $NEW_EUCA/usr/sbin/euca_conf ];
 
219
        then
 
220
            echo "Cannot find new $NEW_EUCA/usr/sbin/euca_conf! Skipping automatic upgrade."
 
221
            exit 1
 
222
        fi
 
223
        
 
224
    # upgrade the conf file
 
225
        export EUCALYPTUS="$NEW_EUCA"
 
226
        $EUCALYPTUS/usr/sbin/euca_conf -d $EUCALYPTUS --upgrade-conf $OLD_EUCA/etc/eucalyptus/eucalyptus.conf $EUCALYPTUS/etc/eucalyptus/eucalyptus.conf 
 
227
    fi
 
228
    echo "Done."
 
229
fi
 
230
 
 
231
if [ "$KEYS" = "Y" ]; then
 
232
    echo "Upgrading keys..."
 
233
    for x in `\ls -ad $OLD_EUCA/var/lib/eucalyptus/keys/* 2>&1 | grep -v policy\.xml` ; do
 
234
        cp -a --preserve $x $NEW_EUCA/var/lib/eucalyptus/keys/
 
235
    done
 
236
    echo "Done."
 
237
fi
 
238
 
 
239
# upgrade the database (and backup)
 
240
if [ "$DB" = "Y" ]; then
 
241
    echo "Upgrading database..."
 
242
    if [ $SAMEVER = "Y" ]; then
 
243
        cp --preserve -a $OLD_EUCA/var/lib/eucalyptus/db/* $NEW_EUCA/var/lib/eucalyptus/db/
 
244
    else
 
245
        # check we have the right binaries
 
246
        if [ -z "$OPENSSL" ]; then
 
247
            echo "Missing openssl, skipping automatic upgrade."
 
248
            exit 1
 
249
        fi
 
250
        # make sure there are files to upgrade from
 
251
        if ( ls $OLD_EUCA/var/lib/eucalyptus/db/* >/dev/null 2>&1 ); then
 
252
        
 
253
        # upgrade the database
 
254
            export EUCALYPTUS="$NEW_EUCA"
 
255
            FILES=`\ls -1 ${EUCALYPTUS}/usr/share/eucalyptus/*.jar | egrep -v ".*eucalyptus-.*1\.6\.1.*"`
 
256
            for FILE in $FILES; do
 
257
                  export CLASSPATH=${FILE}:${CLASSPATH}
 
258
            done
 
259
            $OPENSSL pkcs12 -in ${EUCALYPTUS}/var/lib/eucalyptus/keys/euca.p12 -name eucalyptus -name "eucalyptus" -password pass:eucalyptus  -passin pass:eucalyptus -passout pass:eucalyptus -nodes 2>/dev/null | grep -A30 "friendlyName: eucalyptus" | grep -A26 "BEGIN RSA" > ${EUCALYPTUS}/var/lib/eucalyptus/keys/cloud-pk.pem
 
260
            
 
261
            export EUCALYPTUS_DB="`echo -n eucalyptus | $OPENSSL dgst -sha256 -sign ${EUCALYPTUS}/var/lib/eucalyptus/keys/cloud-pk.pem -hex 2>/dev/null`"
 
262
            export EUCALYPTUS_CLUSTER_CERT="`openssl pkcs12 -in ${EUCALYPTUS}/var/lib/eucalyptus/keys/clusters.p12 -name eucalyptus -name "eucalyptus" -password pass:eucalyptus  -passin pass:eucalyptus -passout pass:eucalyptus -nodes -nokeys 2>/dev/null | sed '1,/friendlyName: cc-/ d ; /friendlyName/,$ d ; /-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' -n | openssl base64 | sed '{:q;N;s/\n//g;s/=/./g;s/+/-/g;s/\//_/g;t q}'`"
 
263
            export EUCALYPTUS_NODE_CERT="`openssl pkcs12 -in ${EUCALYPTUS}/var/lib/eucalyptus/keys/clusters.p12 -name eucalyptus -name "eucalyptus" -password pass:eucalyptus  -passin pass:eucalyptus -passout pass:eucalyptus -nodes -nokeys 2>/dev/null | sed '1,/friendlyName: nc-/ d ; /friendlyName/,$ d ; /-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' -n | openssl base64 | sed '{:q;N;s/\n//g;s/=/./g;s/+/-/g;s/\//_/g;t q}'`"
 
264
            
 
265
            echo "Upgrading your database..."
 
266
            if [ -f ${EUCALYPTUS}/etc/eucalyptus/cloud.d/scripts/Import_${OLD_EUCA_VER_NUM}.groovy ]; then
 
267
                rm -f $NEW_EUCA/var/lib/eucalyptus/db/*.log $NEW_EUCA/var/lib/eucalyptus/db/*.script $NEW_EUCA/var/lib/eucalyptus/db/*.properties
 
268
                if ( ! java org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --classpath ${EUCALYPTUS}/etc/eucalyptus/cloud.d/scripts:$CLASSPATH \
 
269
                    -Deuca.old=${OLD_EUCA} -Deuca.new=${NEW_EUCA} -Deuca.home=${NEW_EUCA} \
 
270
                    -Deuca.var.dir=${NEW_EUCA}/var/lib/eucalyptus -Deuca.conf.dir=${NEW_EUCA} -Deuca.log.dir=${NEW_EUCA}/var/log/eucalyptus \
 
271
                    ${EUCALYPTUS}/etc/eucalyptus/cloud.d/scripts/Import_${OLD_EUCA_VER_NUM}.groovy 2>&1 | egrep -v "(log4j)|(ehcache)" > $EUCALYPTUS/var/log/eucalyptus/upgrade.log ); then
 
272
                    echo "Database upgrade failed! Please check your database before using Eucalyptus."
 
273
                    exit 1
 
274
                fi
 
275
            else
 
276
                echo "Cannot find DB upgrade script from $old_euca_version to $new_euca_version! Skipping DB upgrade."
 
277
            fi
 
278
        fi
 
279
    fi
 
280
    echo "Done."
 
281
fi