aboutsummaryrefslogtreecommitdiff
path: root/files/vserver/build_vserver
blob: ddf37e0cb038a60db19d0f3b414588354e922454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash

NAME="$1"
CONTEXT="$2"
RELEASE="$3"
DEBOOTSTRAP_MIRROR="$4"
VHOSTNAME="$5"
VINTERFACE="$6"

if [ "$VHOSTNAME" != "none" ]; then
  VHOSTNAME="--hostname $VHOSTNAME"
fi

if [ ! -z "$VINTERFACE" ]; then
  VINTERFACE="--interface $VINTERFACE"
fi

# create basic vserver
vserver $NAME build -n $NAME --context $CONTEXT \
        $VHOSTNAME $VINTERFACE -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR || exit 1

# copy in some some defaults
TARGET=/etc/vservers/$NAME/vdir/
cp /etc/apt/{preferences,sources.list} $TARGET/etc/apt/

# this is needed so puppet can find the puppetmaster and creates the right
# certificate
#grep -v $NAME /etc/hosts > $TARGET/etc/hosts
#echo "127.0.0.1 $NAME" >> $TARGET/etc/hosts
echo "127.0.0.1 $NAME" > $TARGET/etc/hosts
#mkdir -p $TARGET/var/lib/puppet/modules/dbp
#cp /var/lib/puppet/modules/dbp/puppet_current.deb $TARGET/var/lib/puppet/modules/dbp/

# Setup is complete, now do the post-install stuff
vserver $NAME start                || exit 1
vserver $NAME exec apt-get update  || exit 1
vserver $NAME exec apt-get upgrade || exit 1

# Install a few needed packages
vserver $NAME exec apt-get -y install lsb-release iproute cron sudo openssh-server locales || exit 1

#vserver $NAME exec dpkg --install var/lib/puppet/modules/dbp/puppet_current.deb
#vserver $NAME exec apt-get -fy install
#echo "Please sign now: puppetca --sign $NAME" >&2

echo "VServer $NAME created"