~free.ekanayaka/landscape-client/lucid-1.5.0-0ubuntu0.10.04.0

« back to all changes in this revision

Viewing changes to dev/landscape-client-vm

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-12-16 10:50:05 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091216105005-svplwdorkgz6vja7
Tags: 1.4.0-0ubuntu0.10.04.0
* New upstream release with several bug fixes:
  - Fix landscape daemons fail to start when too many groups are
    available (LP: #456124)
  - Fix landscape programs wake up far too much. (LP: #340843)
  - Fix Package manager fails with 'no such table: task' (LP #465846)
  - Fix test suite leaving temporary files around (LP #476418)
  - Fix the 1hr long wait for user data to be uploaded following a
    resynchronisation (LP #369000)

* Add support for Ubuntu release upgrades:
  - Add helper function to fetch many files at once (LP: #450629)
  - Handle release-upgrade messages in the packagemanager
    plugin (LP: #455217)
  - Add a release-upgrader task handler (LP: #462543)
  - Support upgrade-tool environment variables (LP: #463321)

* Add initial support for Smart package locking:
  - Detect and report changes about Smart package locks (#488108)

* Packaging fixes:
  - Turn unnecessary Pre-Depends on python-gobject into a regular Depends
  - If it's empty, remove /etc/landscape upon purge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
help () {
 
4
    cat <<EOF
 
5
$0 [OPTION] ... <release>: build a landscape-client VM for the specified release
 
6
 
 
7
Available options:
 
8
 
 
9
  -m, --mirror <mirror>      The Ubuntu mirror to use to build the VM, and
 
10
                             for the APT sources inside the VM itself.
 
11
 
 
12
                             If you want to use apt-proxy, you have to modify the
 
13
                             apt-proxy-v2.conf file to make apt-proxy listen to
 
14
                             your actual network interface address, instead of
 
15
                             the loopback one. For example:
 
16
 
 
17
                             ;; Server IP to listen on
 
18
                             address = 192.168.1.162
 
19
 
 
20
  -s, --server <host>        The hostname of the Landscape server the client
 
21
                             should connect to.
 
22
 
 
23
  -a, --account <account>    The name of the Landscape account to use.
 
24
 
 
25
  -p, --password <password>  The password for the Landscape account.
 
26
 
 
27
  -P, --profile <profile>    Package profile to use, can be server or desktop.
 
28
 
 
29
  -k, --ssl-key <key>        Specify an SSL key to be used in the client config.
 
30
 
 
31
For example, this script can be invoked like this:
 
32
 
 
33
./dev/landscape-client-vm --password <LANDSCAPE_DEVEL_ACCOUNT_PW> intrepid
 
34
 
 
35
where <LANDSCAPE_DEVEL_ACCOUNT_PW> is the account password of the landscape-devel
 
36
account on the Landscape staging server (or you can specify another account with
 
37
the --account parameter).
 
38
 
 
39
The built VM will be stored under ./build/intrepid along with some other
 
40
files. To launch the VM, cd to ./build/intrepid and issue:
 
41
 
 
42
./run
 
43
 
 
44
Once it's booted you can log into it with:
 
45
 
 
46
./ssh
 
47
 
 
48
EOF
 
49
}
 
50
 
 
51
OPTS=$(getopt -o hm:s:a:p:P:k: --long help,mirror:,server:,account:,password:,profile:,ssl-key: -- "$@")
 
52
 
 
53
if [ $? != 0 ]; then
 
54
    exit 1
 
55
fi
 
56
 
 
57
eval set -- "$OPTS"
 
58
 
 
59
MIRROR=http://archive.ubuntu.com/ubuntu
 
60
SERVER=staging.landscape.canonical.com
 
61
ACCOUNT=landscape-devel
 
62
PASSWORD=
 
63
PROFILE=server
 
64
SSL_KEY=
 
65
 
 
66
while true ; do
 
67
    case "$1" in
 
68
        -h|--help) help; exit 1; shift ;;
 
69
        -m|--mirror) MIRROR=$2; shift 2 ;;
 
70
        -s|--server) SERVER=$2; shift 2;;
 
71
        -a|--account) ACCOUNT=$2; shift 2;;
 
72
        -p|--password) PASSWORD=$2; shift 2;;
 
73
        -P|--profile) PROFILE=$2; shift 2;;
 
74
        -S|--ssl-key) SSL_KEY=$2; shift 2;;
 
75
        --) shift ; break ;;
 
76
        *) echo "Internal error!" ; exit 1 ;;
 
77
    esac
 
78
done
 
79
 
 
80
if [ "$1" = "" ]; then
 
81
    help
 
82
    exit
 
83
fi
 
84
 
 
85
RELEASE=$1
 
86
TOPDIR=$(pwd)/build/${RELEASE}-${PROFILE}
 
87
SSH_KEY=$TOPDIR/ssh_key
 
88
SSH_PORT=3322
 
89
PPA=landscape/ppa
 
90
ROOTSIZE=8192
 
91
 
 
92
rm -fR $TOPDIR
 
93
mkdir -p $TOPDIR
 
94
ssh-keygen -N '' -f $SSH_KEY
 
95
 
 
96
cd $TOPDIR
 
97
 
 
98
cat > config <<EOF
 
99
[client]
 
100
url = https://${SERVER}/message-system
 
101
computer_title = ${RELEASE} test VM $$
 
102
data_path = /var/lib/landscape/client
 
103
script_users = ALL
 
104
ping_url = http://${SERVER}/ping
 
105
include_manager_plugins = ScriptExecution
 
106
account_name = ${ACCOUNT}
 
107
registration_password = ${PASSWORD}
 
108
#log_level = debug
 
109
EOF
 
110
 
 
111
if ! [ "$WITH_SSL" = "" ]; then
 
112
    echo ssl_public_key = $SSL_KEY >> config
 
113
fi
 
114
 
 
115
cat > script-wrapper <<EOF
 
116
#!/bin/sh -e
 
117
chroot \$1 /root/script
 
118
EOF
 
119
chmod 755 script-wrapper
 
120
 
 
121
cat> ppa-key <<EOF
 
122
-----BEGIN PGP PUBLIC KEY BLOCK-----
 
123
Version: SKS 1.0.10
 
124
 
 
125
mI0ESXN/egEEAOgRYISU9dnQm4BB5ZEEwKT+NKUDNd/DhMYdtBMw9Yk7S5cyoqpbtwoPJVzK
 
126
AXxq+ng5e3yYypSv98pLMr5UF09FGaeyGlD4s1uaVFWkFCO4jsTg7pWIY6qzO/jMxB5+Yu/G
 
127
0GjWQMNKxFk0oHMa0PhNBZtdPacVz65mOVmCsh/lABEBAAG0G0xhdW5jaHBhZCBQUEEgZm9y
 
128
IExhbmRzY2FwZYi2BBMBAgAgBQJJc396AhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQ
 
129
boWobkZStOb+rwP+ONKUWeX+MTIPqGWkknBPV7jm8nyyIUojC4IhS+9YR6GYnn0hMABSkEHm
 
130
IV73feKmrT2GESYI1UdYeKiOkWsPN/JyBk+eTvKet0qsw5TluqiHSW+LEi/+zUyrS3dDMX3o
 
131
yaLgYa+UkjIyxnaKLkQuCiS+D+fYwnJulIkhaKObtdE=
 
132
=UwRd
 
133
-----END PGP PUBLIC KEY BLOCK-----
 
134
EOF
 
135
 
 
136
cat > script <<EOF
 
137
#!/bin/sh -e
 
138
chown landscape /etc/landscape/client.conf
 
139
chmod 600 /etc/landscape/client.conf
 
140
apt-key add /root/ppa-key
 
141
echo "RUN=1" > /etc/default/landscape-client
 
142
EOF
 
143
chmod 755 script
 
144
 
 
145
cat > manifest <<EOF
 
146
ppa-key /root
 
147
script /root/script
 
148
config /etc/landscape/client.conf
 
149
EOF
 
150
 
 
151
if [ "$WITH_SSL" = "yes" ]; then
 
152
    echo /etc/landscape/certs/sample_ca.crt /etc/landscape/client.conf.ssl_public_key >> manifest
 
153
fi
 
154
 
 
155
cat > ssh <<EOF
 
156
#!/bin/sh
 
157
exec ssh -p $SSH_PORT -i $SSH_KEY -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost
 
158
EOF
 
159
chmod 755 ssh
 
160
 
 
161
cat > run <<EOF
 
162
#!/bin/sh
 
163
exec kvm --redir tcp:$SSH_PORT::22 -m 1280 -smp 1 -drive file=$TOPDIR/ubuntu-kvm/disk0.qcow2 "$@"
 
164
EOF
 
165
chmod 755 run
 
166
 
 
167
ADDPKGS="--addpkg=landscape-client --addpkg=openssh-server"
 
168
 
 
169
if [ "$PROFILE" = "server" ]; then
 
170
    ADDPKGS="$ADDPKGS --addpkg apache2-mpm-prefork --addpkg postgresql --addpkg postfix"
 
171
else
 
172
    ADDPKGS="$ADDPKGS --addpkg ubuntu-desktop"
 
173
fi
 
174
 
 
175
if [ -n "$TMPDIR" ]; then
 
176
    TEMP_DIR_OPT="-t $TMPDIR"
 
177
fi
 
178
 
 
179
sudo ubuntu-vm-builder kvm "$RELEASE" --rootsize=$ROOTSIZE --mirror="$MIRROR" --ppa="$PPA" $ADDPKGS --execscript=./script-wrapper --copy=manifest --ssh-key=$SSH_KEY.pub $TEMP_DIR_OPT