aboutsummaryrefslogtreecommitdiff
path: root/files/vserver
diff options
context:
space:
mode:
Diffstat (limited to 'files/vserver')
-rw-r--r--files/vserver/build_vserver36
-rwxr-xr-xfiles/vserver/create_openvpn_interface10
-rwxr-xr-xfiles/vserver/destroy_openvpn_interface9
3 files changed, 55 insertions, 0 deletions
diff --git a/files/vserver/build_vserver b/files/vserver/build_vserver
new file mode 100644
index 0000000..0f0cea7
--- /dev/null
+++ b/files/vserver/build_vserver
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+NAME=$1
+CONTEXT=$2
+RELEASE = $3
+DEBOOTSTRAP_MIRROR = $4
+# create basic vserver
+vserver $NAME build -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR
+
+# default settings
+echo $NAME >/etc/vservers/$NAME/uts/nodename
+echo $CONTEXT >/etc/vservers/$NAME/context
+
+# 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
+#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
+vserver $NAME exec dselect update
+# install a few packages needed for facter
+vserver $NAME exec apt-get -y install lsb-release iproute
+#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"
diff --git a/files/vserver/create_openvpn_interface b/files/vserver/create_openvpn_interface
new file mode 100755
index 0000000..87d9144
--- /dev/null
+++ b/files/vserver/create_openvpn_interface
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+DEV="$1"
+SUBNET="$2"
+
+openvpn --mktun --dev "$DEV"
+ip link set dev "$DEV" txqueuelen 100
+ifconfig "$DEV" "$SUBNET".1 pointopoint "$SUBNET".2 mtu 1500
+route add -net "$SUBNET".0 netmask 255.255.255.0 gw "$SUBNET".2
+
diff --git a/files/vserver/destroy_openvpn_interface b/files/vserver/destroy_openvpn_interface
new file mode 100755
index 0000000..aa89ed4
--- /dev/null
+++ b/files/vserver/destroy_openvpn_interface
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+DEV="$1"
+SUBNET="$2"
+
+route del -net "$SUBNET".0 netmask 255.255.255.0 gw "$SUBNET".2
+ifconfig "$DEV" down
+openvpn --rmtun --dev "$DEV"
+