Skip to content

Commit 33fd689

Browse files
lsimonsyadvr
authored andcommitted
CLOUDSTACK-7143: use shar to inject cloud-scripts from working copy
The current build downloads its script from master by fetching a cloudstack tarball. Besides being an unneeded load on the apache git server, this is a problem when working on a branch and wanting to inject a different set of scripts. It also makes it pretty likely that the injected copy of the script will not match what a production release wants, so there is very little chance of not needing to overwrite the scripts. Ideally we would just rsync over some files. However, veewee does not provide an option to do that. In order to keep a 'cleanly veewee-only' build possible, and work with any recent veewee version, in this change we restor to using shar (http://en.wikipedia.org/wiki/Shar) to produce an archive which can execute as a script, which we feed to veewee to execute.
1 parent 35ba684 commit 33fd689

4 files changed

Lines changed: 65 additions & 16 deletions

File tree

tools/appliance/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ function create_definition() {
244244
set -e
245245
add_on_exit rm -rf "definitions/${appliance_build_name}"
246246
fi
247+
248+
./shar_cloud_scripts.sh
249+
add_on_exit rm -f cloud_scripts_shar_archive.sh
247250
}
248251

249252
function prepare() {

tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,13 @@ function configure_apache2() {
3131
}
3232

3333
function install_cloud_scripts() {
34-
# Get config files from master
35-
snapshot_url="https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=snapshot;h=HEAD;sf=tgz"
36-
snapshot_dir="/opt/cloudstack*"
37-
cd /opt
38-
wget --no-check-certificate $snapshot_url -O cloudstack.tar.gz
39-
tar -zxvf cloudstack.tar.gz --wildcards 'cloudstack-HEAD-???????/systemvm'
40-
cp -rv $snapshot_dir/systemvm/patches/debian/config/* /
41-
cp -rv $snapshot_dir/systemvm/patches/debian/vpn/* /
42-
mkdir -p /usr/share/cloud/
43-
cd $snapshot_dir/systemvm/patches/debian/config
44-
tar -cvf /usr/share/cloud/cloud-scripts.tar *
45-
cd $snapshot_dir/systemvm/patches/debian/vpn
46-
tar -rvf /usr/share/cloud/cloud-scripts.tar *
47-
cd /opt
48-
rm -fr $snapshot_dir cloudstack.tar.gz
34+
# ./cloud_scripts/ has been put there by ../../cloud_scripts_shar_archive.sh
35+
rsync -av ./cloud_scripts/ /
36+
chmod +x /opt/cloud/bin/* \
37+
/root/{clearUsageRules.sh,reconfigLB.sh,monitorServices.py} \
38+
/etc/init.d/{cloud,cloud-early-config,cloud-passwd-srvr,postinit} \
39+
/etc/cron.daily/cloud-cleanup \
40+
/etc/profile.d/cloud.sh
4941

5042
chkconfig --add cloud-early-config
5143
chkconfig cloud-early-config on
@@ -73,6 +65,7 @@ configure_services() {
7365
mkdir -p /var/lib/haproxy
7466

7567
install_cloud_scripts
68+
do_signature
7669

7770
chkconfig xl2tpd off
7871

@@ -84,7 +77,6 @@ configure_services() {
8477
chkconfig radvd off
8578

8679
configure_apache2
87-
do_signature
8880
}
8981

9082
return 2>/dev/null || configure_services

tools/appliance/definitions/systemvmtemplate/definition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
# turning it into a systemvm
8686
'install_systemvm_packages.sh',
8787
'configure_conntrack.sh',
88+
'../../cloud_scripts_shar_archive.sh',
8889
'configure_systemvm_services.sh',
8990
'authorized_keys.sh',
9091
# cleanup & space-saving
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
# since veewee wants .sh files to execute, we'll give it a shar
20+
21+
set -e
22+
set -x
23+
24+
# where we are running this script from
25+
CURR_DIR=${PWD}
26+
# where this script is
27+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28+
# where cloudstack is checked out
29+
cd ${SCRIPT_DIR}/../..
30+
CLOUDSTACK_DIR=${PWD}
31+
cd ${CURR_DIR}
32+
# ensure we are running in isolation
33+
TEMP_DIR=`mktemp -d -t shar_cloud`
34+
35+
cd ${TEMP_DIR}
36+
mkdir cloud_scripts
37+
mkdir -p cloud_scripts/opt/cloudstack
38+
cp -r ${CLOUDSTACK_DIR}/systemvm/patches/debian/config/* cloud_scripts/
39+
cp -r ${CLOUDSTACK_DIR}/systemvm/patches/debian/vpn/* cloud_scripts/
40+
41+
mkdir -p cloud_scripts/usr/share/cloud
42+
cd ${CLOUDSTACK_DIR}/systemvm/patches/debian/config
43+
tar -cf ${TEMP_DIR}/cloud_scripts/usr/share/cloud/cloud-scripts.tar *
44+
cd ${CLOUDSTACK_DIR}/systemvm/patches/debian/vpn
45+
tar -rf ${TEMP_DIR}/cloud_scripts/usr/share/cloud/cloud-scripts.tar *
46+
47+
cd ${TEMP_DIR}
48+
shar `find . -print` > ${CURR_DIR}/cloud_scripts_shar_archive.sh
49+
50+
cd ${CURR_DIR}
51+
rm -rf ${TEMP_DIR}
52+
chmod +x cloud_scripts_shar_archive.sh
53+
echo cloud_scripts are in cloud_scripts_shar_archive.sh

0 commit comments

Comments
 (0)