blob: 74efaff94b57f697edd97b16c10740e1b3e74788 [file] [log] [blame]
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001#!/bin/bash
2
Renuka Aptece59d642012-02-02 16:09:23 -08003set -x
4
Anthony Youngb62b4ca2011-10-26 22:29:08 -07005# Configurable nuggets
Anthony Young3eb8f592011-10-26 23:11:52 -07006GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
Anthony Youngb62b4ca2011-10-26 22:29:08 -07007STAGING_DIR=${STAGING_DIR:-stage}
8DO_TGZ=${DO_TGZ:-1}
Anthony Youngb62b4ca2011-10-26 22:29:08 -07009
Anthony Youngb62b4ca2011-10-26 22:29:08 -070010# Install basics
11chroot $STAGING_DIR apt-get update
Anthony Youngb62b4ca2011-10-26 22:29:08 -070012chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
13chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
14chroot $STAGING_DIR pip install xenapi
15
16# Install guest utilities
17XEGUEST=xe-guest-utilities_5.6.100-651_amd64.deb
18wget http://images.ansolabs.com/xen/$XEGUEST -O $XEGUEST
19cp $XEGUEST $STAGING_DIR/root
20chroot $STAGING_DIR dpkg -i /root/$XEGUEST
21chroot $STAGING_DIR update-rc.d -f xe-linux-distribution remove
22chroot $STAGING_DIR update-rc.d xe-linux-distribution defaults
23
24# Make a small cracklib dictionary, so that passwd still works, but we don't
25# have the big dictionary.
26mkdir -p $STAGING_DIR/usr/share/cracklib
27echo a | chroot $STAGING_DIR cracklib-packer
28
29# Make /etc/shadow, and set the root password
30chroot $STAGING_DIR "pwconv"
Anthony Young3eb8f592011-10-26 23:11:52 -070031echo "root:$GUEST_PASSWORD" | chroot $STAGING_DIR chpasswd
Anthony Youngb62b4ca2011-10-26 22:29:08 -070032
33# Put the VPX into UTC.
34rm -f $STAGING_DIR/etc/localtime
35
36# Add stack user
37chroot $STAGING_DIR groupadd libvirtd
38chroot $STAGING_DIR useradd stack -s /bin/bash -d /opt/stack -G libvirtd
Anthony Young3eb8f592011-10-26 23:11:52 -070039echo stack:$GUEST_PASSWORD | chroot $STAGING_DIR chpasswd
Anthony Youngb62b4ca2011-10-26 22:29:08 -070040echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers
41
42# Give ownership of /opt/stack to stack user
43chroot $STAGING_DIR chown -R stack /opt/stack
44
45# Make our ip address hostnames look nice at the command prompt
46echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/opt/stack/.bashrc
47echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/root/.bashrc
48echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/etc/profile
49
50function setup_vimrc {
51 if [ ! -e $1 ]; then
52 # Simple but usable vimrc
53 cat > $1 <<EOF
54syntax on
55se ts=4
56se expandtab
57se shiftwidth=4
58EOF
59 fi
60}
61
62# Setup simple .vimrcs
63setup_vimrc $STAGING_DIR/root/.vimrc
64setup_vimrc $STAGING_DIR/opt/stack/.vimrc
65
66if [ "$DO_TGZ" = "1" ]; then
67 # Compress
68 rm -f stage.tgz
69 tar cfz stage.tgz stage
70fi