Skip to content

Commit 04d51c9

Browse files
committed
CLOUDSTACK-1066: Fix only one postinstall script, install packages etc.
- Remove different scripts, just use postinstall.sh that runs after basic appliance is built using veewee - Port package installation method from old script - Time the installation/build process Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 1fd0563 commit 04d51c9

5 files changed

Lines changed: 148 additions & 99 deletions

File tree

‎tools/appliance/definitions/systemvmtemplate/base.sh‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎tools/appliance/definitions/systemvmtemplate/cleanup.sh‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎tools/appliance/definitions/systemvmtemplate/definition.rb‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
5353
:shutdown_cmd => "halt -p",
5454
:postinstall_files => [
55-
"base.sh",
56-
"cleanup.sh",
57-
"zerodisk.sh"
55+
"postinstall.sh",
5856
],
5957
:postinstall_timeout => "10000"
6058
})
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
set -e
19+
set -x
20+
21+
IMAGENAME=systemvm
22+
LOCATION=/var/lib/images/systemvm
23+
PASSWORD=password
24+
HOSTNAME=systemvm
25+
SIZE=2048
26+
DEBIAN_MIRROR=ftp.us.debian.org/debian
27+
MINIMIZE=true
28+
CLOUDSTACK_RELEASE=4.1.0
29+
30+
init() {
31+
# Update the box
32+
apt-get -y update
33+
apt-get -y install linux-headers-$(uname -r) build-essential
34+
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev
35+
apt-get -y install curl unzip
36+
apt-get clean
37+
38+
# Set up sudo
39+
echo 'vagrant ALL=NOPASSWD:ALL' > /etc/sudoers.d/vagrant
40+
41+
# Tweak sshd to prevent DNS resolution (speed up logins)
42+
echo 'UseDNS no' >> /etc/ssh/sshd_config
43+
44+
# Remove 5s grub timeout to speed up booting
45+
echo <<EOF > /etc/default/grub
46+
# If you change this file, run 'update-grub' afterwards to update
47+
# /boot/grub/grub.cfg.
48+
49+
GRUB_DEFAULT=0
50+
GRUB_TIMEOUT=0
51+
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
52+
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
53+
GRUB_CMDLINE_LINUX="debian-installer=en_US"
54+
EOF
55+
56+
update-grub
57+
}
58+
59+
install_packages() {
60+
DEBIAN_FRONTEND=noninteractive
61+
DEBIAN_PRIORITY=critical
62+
DEBCONF_DB_OVERRIDE=’File{/root/config.dat}’
63+
export DEBIAN_FRONTEND DEBIAN_PRIORITY DEBCONF_DB_OVERRIDE
64+
65+
#basic stuff
66+
chroot . apt-get --no-install-recommends -q -y --force-yes install rsyslog logrotate cron chkconfig insserv net-tools ifupdown vim-tiny netbase iptables openssh-server grub-legacy e2fsprogs dhcp3-client dnsmasq tcpdump socat wget python bzip2 sed gawk diff grep gzip less tar telnet ftp rsync traceroute psmisc lsof procps monit inetutils-ping iputils-arping httping dnsutils zip unzip ethtool uuid file iproute acpid iptables-persistent virt-what sudo
67+
#fix hostname in openssh-server generated keys
68+
sed -i "s/root@\(.*\)$/root@systemvm/g" etc/ssh/ssh_host_*.pub
69+
70+
#sysstat
71+
chroot . echo 'sysstat sysstat/enable boolean true' | chroot . debconf-set-selections
72+
chroot . apt-get --no-install-recommends -q -y --force-yes install sysstat
73+
#apache
74+
chroot . apt-get --no-install-recommends -q -y --force-yes install apache2 ssl-cert
75+
#haproxy
76+
chroot . apt-get --no-install-recommends -q -y --force-yes install haproxy
77+
#dnsmasq
78+
chroot . apt-get --no-install-recommends -q -y --force-yes install dnsmasq
79+
#nfs client
80+
chroot . apt-get --no-install-recommends -q -y --force-yes install nfs-common
81+
#vpn stuff
82+
chroot . apt-get --no-install-recommends -q -y --force-yes install xl2tpd openswan bcrelay ppp ipsec-tools tdb-tools
83+
#vmware tools
84+
chroot . apt-get --no-install-recommends -q -y --force-yes install open-vm-tools
85+
#xenstore utils
86+
chroot . apt-get --no-install-recommends -q -y --force-yes install xenstore-utils libxenstore3.0
87+
#keepalived and conntrackd
88+
chroot . apt-get --no-install-recommends -q -y --force-yes install keepalived conntrackd ipvsadm libnetfilter-conntrack3 libnl1
89+
#ipcalc
90+
chroot . apt-get --no-install-recommends -q -y --force-yes install ipcalc
91+
92+
echo "***** getting sun jre 6*********"
93+
chroot . echo 'sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
94+
sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
95+
sun-java6-jre sun-java6-jre/stopthread boolean true
96+
sun-java6-jre sun-java6-jre/jcepolicy note
97+
sun-java6-bin shared/present-sun-dlj-v1-1 note
98+
sun-java6-jre shared/present-sun-dlj-v1-1 note ' | chroot . debconf-set-selections
99+
chroot . apt-get --no-install-recommends -q -y install sun-java6-jre
100+
}
101+
102+
cleanup() {
103+
# Clean up
104+
apt-get -y remove linux-headers-$(uname -r) build-essential
105+
apt-get -y autoremove
106+
107+
# Removing leftover leases and persistent rules
108+
echo "cleaning up dhcp leases"
109+
rm /var/lib/dhcp/*
110+
111+
# Make sure Udev doesn't block our network
112+
echo "cleaning up udev rules"
113+
rm /etc/udev/rules.d/70-persistent-net.rules
114+
mkdir /etc/udev/rules.d/70-persistent-net.rules
115+
rm -rf /dev/.udev/
116+
rm /lib/udev/rules.d/75-persistent-net-generator.rules
117+
118+
echo "Adding a 2 sec delay to the interface up, to make the dhclient happy"
119+
echo "pre-up sleep 2" >> /etc/network/interfaces
120+
}
121+
122+
finalize() {
123+
# Zero out the free space to save space in the final image:
124+
dd if=/dev/zero of=/EMPTY bs=1M
125+
rm -f /EMPTY
126+
}
127+
128+
129+
echo "*************STARTING POSTINST SCRIPT********************"
130+
begin=$(date +%s)
131+
132+
echo "*************INITIALIZING BASE SYSTEM********************"
133+
init
134+
135+
echo "*************INSTALLING PACKAGES********************"
136+
install_packages
137+
138+
echo "*************CLEANING UP********************"
139+
cleanup
140+
141+
echo "*************FINALIZING IMAGE********************"
142+
finalize
143+
144+
fin=$(date +%s)
145+
t=$((fin-begin))
146+
147+
echo "Finished building systemvm appliance in $t seconds"

‎tools/appliance/definitions/systemvmtemplate/zerodisk.sh‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)