devstack/tools/xen/prepare_guest.sh
Mate Lakat f34cb85135 xenapi: preinstall python netaddr
On our CI system, the devstack instance was reporting errors, that are
related to devstack's address_in_net function - that requires the python
netaddr library to be installed. This patch preinstalls this python
package.

Fixes bug 1097667

Change-Id: I8af199427f06cfdf0a68d96d87fe3e541199dca7
2013-07-12 17:11:07 +01:00

84 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# This script is run on an Ubuntu VM.
# This script is inserted into the VM by prepare_guest_template.sh
# and is run when that VM boots.
# It customizes a fresh Ubuntu install, so it is ready
# to run stack.sh
#
# This includes installing the XenServer tools,
# creating the user called "stack",
# and shuts down the VM to signal the script has completed
set -o errexit
set -o nounset
set -o xtrace
# Configurable nuggets
GUEST_PASSWORD="$1"
XS_TOOLS_PATH="$2"
STACK_USER="$3"
# Install basics
apt-get update
apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo python-netaddr
pip install xenapi
# Install XenServer guest utilities
dpkg -i $XS_TOOLS_PATH
update-rc.d -f xe-linux-distribution remove
update-rc.d xe-linux-distribution defaults
# Make a small cracklib dictionary, so that passwd still works, but we don't
# have the big dictionary.
mkdir -p /usr/share/cracklib
echo a | cracklib-packer
# Make /etc/shadow, and set the root password
pwconv
echo "root:$GUEST_PASSWORD" | chpasswd
# Put the VPX into UTC.
rm -f /etc/localtime
# Add stack user
groupadd libvirtd
useradd $STACK_USER -s /bin/bash -d /opt/stack -G libvirtd
echo $STACK_USER:$GUEST_PASSWORD | chpasswd
echo "$STACK_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Give ownership of /opt/stack to stack user
chown -R $STACK_USER /opt/stack
# Make our ip address hostnames look nice at the command prompt
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> /opt/stack/.bashrc
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> /root/.bashrc
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> /etc/profile
function setup_vimrc {
if [ ! -e $1 ]; then
# Simple but usable vimrc
cat > $1 <<EOF
syntax on
se ts=4
se expandtab
se shiftwidth=4
EOF
fi
}
# Setup simple .vimrcs
setup_vimrc /root/.vimrc
setup_vimrc /opt/stack/.vimrc
# remove self from local.rc
# so this script is not run again
rm -rf /etc/rc.local
# Restore rc.local file
cp /etc/rc.local.preparebackup /etc/rc.local
# shutdown to notify we are done
shutdown -h now