Wheezy-guest-build-scripts

From Linux-VServer

Revision as of 23:49, 18 May 2013 by SergiuszPawlowicz (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A simple build script for wheezy guest:

#!/bin/bash
# Serge Pawlowicz, <linux-vserver@pawlowicz.name>, GNU Free Documentation License 1.2
: ${1?"Usage: $0 mxc2.it-zone.org 1001 10.13.10.1 /vservers"}
set -x -e
####
NAME=$1
CONTEXT=$2
IP=$3
#LOC=$4
DIR=$4
####
NICEBUILD="ionice -c 3 chrt --idle 0"
NICE=10
MEMORY=4G
MEMSW=5G
# i am using apt cacher: apt-cache-ng - but you can adapt the scripot to utiize other mirrors setting PROXY to "http:/"
#PROXY="http:/"
PROXY=http://10.100.100.2:3142
MIRROR=$PROXY/free.hands.com/debian
#MIRROR=http://http.debian.net/debian
SECURITY=$PROXY/security.debian.org/
DOTDEB=$PROXY/packages.dotdeb.org
PERCONA=$PROXY/repo.percona.com/apt
IFACE4=dummy0
IP6=${IP//./:}
IP6PRE="2000:45a4:89:63b" # prefix from your uplink
IP6PREFIX="/64" # prety standard one is /64
IFACE6=eth1 # iface
#
SHORT=`echo $NAME|cut -f1 -d\.`
$NICEBUILD vserver $SHORT build -m debootstrap --hostname $NAME --context $CONTEXT \
        --interface $IFACE4:$IP/32 \
        --initstyle sysv \
        --interface $IFACE6:$IP6PRE:$IP6$IP6PREFIX \
        --root $DIR \
        --flags VIRT_MEM \
        -- -d wheezy -m $MIRROR -- --verbose --components main,contrib,non-free \
        --include openssh-client,openssh-server,locales,locales-all,less,iproute,\
             htop,vim-syntax-gtk,rsync,build-essential,libssl-dev,tcpdump,libglib2.0dev,\
             liblua5.1-0-dev,libpcre3-dev,subversion,sudo,psmisc,python,strace,git-core,\
             apg,byobu,vim,nullmailer,w3m,bind9-host,wget,curl
echo default > /etc/vservers/$SHORT/apps/init/mark
echo $NICE > /etc/vservers/$SHORT/nice
mkdir /etc/vservers/$SHORT/cgroup || true
echo $MEMORY > /etc/vservers/$SHORT/cgroup/memory.limit_in_bytes
echo $MEMSW > /etc/vservers/$SHORT/cgroup/memory.memsw.limit_in_bytes
#echo VIRT_MEM > /etc/vservers/$SHORT/flags
vserver $SHORT start
cat > $DIR/$SHORT/etc/apt/sources.list <<EOF
deb $MIRROR wheezy main contrib non-free
deb $MIRROR wheezy-backports main contrib non-free
deb $SECURITY wheezy/updates main contrib non-free
deb $DOTDEB wheezy all
deb $PERCONA wheezy main
EOF
cat > $DIR/$SHORT/etc/apt/preferences.d/backports <<EOF
Package: *
Pin: release a=wheezy-backports
Pin-Priority: 500
EOF
cat > $DIR/$SHORT/etc/apt/preferences.d/dotdeb <<EOF
Package: *
Pin: release l=packages.dotdeb.org
Pin-Priority: 550
EOF
cat > $DIR/$SHORT/etc/apt/preferences.d/percona <<EOF
Package: *
Pin: release o=Percona Development Team
Pin-Priority: 1001
EOF
#
vserver $SHORT curl http://www.dotdeb.org/dotdeb.gpg > /tmp/dotdeb.gpg && cat dotdeb.gpg | apt-key add -
vserver $SHORT gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && gpg -a --export CD2EFD2A | apt-key add -
vserver $SHORT apt-get --assume-yes --force-yes -f install
vserver $SHORT apt-get --assume-yes --force-yes update
vserver $SHORT apt-get --assume-yes --force-yes dist-upgrade
vserver $SHORT exec apt-get clean
vserver $SHORT stop
vserver $SHORT start
Personal tools