4 # close stdin, as with ubuntu and debian VMs this script tends to hang and wait for input ..
13 # pkgs parsing utilities + lbuild-bridge.sh
14 export PATH=$(dirname $0):$PATH
16 # old guests have e.g. mount in /bin but this is no longer part of
17 # the standard PATH in recent hosts after usrmove, so let's keep it simple
18 export PATH=$PATH:/bin:/sbin
24 DEFAULT_PERSONALITY=linux64
31 # the network interface name as seen from the container
35 FEDORA_PREINSTALLED="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils openssh-server openssh-clients"
36 DEBIAN_PREINSTALLED="openssh-server openssh-client"
38 ########## networking utilities
39 function gethostbyname () {
41 python -c "import socket; print socket.gethostbyname('"$hostname"')" 2> /dev/null
44 # e.g. 21 -> 255.255.248.0
45 function masklen_to_netmask () {
50 if not (masklen>=1 and masklen<=32):
51 print "Wrong masklen",masklen
59 result.append(masklen)
61 print ".".join([ str(256-2**(8-i)) for i in result ])
66 ##############################
67 # return yum or debootstrap
68 function package_method () {
71 f[0-9]*|centos[0-9]*|sl[0-9]*) echo yum ;;
72 squeeze|wheezy|jessie|oneiric|precise|quantal|raring|saucy) echo debootstrap ;;
73 *) echo Unknown distro $fcdistro ;;
77 # return arch from debian distro and personality
78 function canonical_arch () {
81 case $(package_method $fcdistro) in
83 case $personality in *32) echo i386 ;; *64) echo x86_64 ;; *) echo Unknown-arch-1 ;; esac ;;
85 case $personality in *32) echo i386 ;; *64) echo amd64 ;; *) echo Unknown-arch-2 ;; esac ;;
87 echo Unknown-arch-3 ;;
91 # the new test framework creates /timestamp in /vservers/<name> *before* populating it
92 function almost_empty () {
94 # non existing is fine
95 [ ! -d $dir ] && return 0;
96 # need to have at most one file
97 count=$(cd $dir; ls | wc -l); [ $count -le 1 ];
100 ##############################
101 function fedora_install() {
105 cache=/var/cache/lxc/fedora/$arch/$release
107 mkdir -p /var/lock/subsys/
109 flock -n -x 200 || { echo "Cache repository is busy." ; return 1 ; }
111 if [ ! -e "$cache/rootfs" ]; then
112 echo "Getting cache download in $cache/rootfs ... "
113 fedora_download || { echo "Failed to download 'fedora base'"; return 1; }
115 echo "Updating cache $cache/rootfs ..."
116 if ! yum --installroot $cache/rootfs -y --nogpgcheck update ; then
117 echo "Failed to update 'fedora base', continuing with last known good cache"
119 echo "Update finished"
123 echo "Copy $cache/rootfs to $lxc_root ... "
124 rsync -a $cache/rootfs/ $lxc_root/
128 ) 200>/var/lock/subsys/lxc
133 function fedora_download() {
135 # check the mini fedora was not already downloaded
136 INSTALL_ROOT=$cache/partial
139 # download a mini fedora into a cache
140 echo "Downloading fedora minimal ..."
142 mkdir -p $INSTALL_ROOT || { echo "Failed to create '$INSTALL_ROOT' directory" ; return 1; }
144 mkdir -p $INSTALL_ROOT/etc/yum.repos.d
145 mkdir -p $INSTALL_ROOT/dev
146 mknod -m 0444 $INSTALL_ROOT/dev/random c 1 8
147 mknod -m 0444 $INSTALL_ROOT/dev/urandom c 1 9
149 # copy yum config and repo files
150 cp /etc/yum.conf $INSTALL_ROOT/etc/
151 cp /etc/yum.repos.d/fedora* $INSTALL_ROOT/etc/yum.repos.d/
153 # append fedora repo files with desired $release and $basearch
154 for f in $INSTALL_ROOT/etc/yum.repos.d/* ; do
155 sed -i "s/\$basearch/$arch/g; s/\$releasever/$release/g;" $f
158 MIRROR_URL=http://mirror.onelab.eu/fedora/releases/$release/Everything/$arch/os
159 RELEASE_URL1="$MIRROR_URL/Packages/fedora-release-$release-1.noarch.rpm"
160 # with fedora18 the rpms are scattered by first name
161 RELEASE_URL2="$MIRROR_URL/Packages/f/fedora-release-$release-1.noarch.rpm"
162 RELEASE_TARGET=$INSTALL_ROOT/fedora-release-$release.noarch.rpm
164 for attempt in $RELEASE_URL1 $RELEASE_URL2; do
165 if curl -f $attempt -o $RELEASE_TARGET ; then
166 echo "Retrieved $attempt"
170 echo "Failed attempt $attempt"
173 [ -n "$found" ] || { echo "Could not retrieve fedora-release rpm - exiting" ; exit 1; }
175 mkdir -p $INSTALL_ROOT/var/lib/rpm
176 rpm --root $INSTALL_ROOT --initdb
177 # when installing f12 this apparently is already present, so ignore result
178 rpm --root $INSTALL_ROOT -ivh $INSTALL_ROOT/fedora-release-$release.noarch.rpm || :
179 # however f12 root images won't get created on a f18 host
180 # (the issue here is the same as the one we ran into when dealing with a vs-box)
181 # in a nutshell, in f12 the glibc-common and filesystem rpms have an apparent conflict
182 # >>> file /usr/lib/locale from install of glibc-common-2.11.2-3.x86_64 conflicts
183 # with file from package filesystem-2.4.30-2.fc12.x86_64
184 # in fact this was - of course - allowed by f12's rpm but later on a fix was made
185 # http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=cf1095648194104a81a58abead05974a5bfa3b9a
186 # So ideally if we want to be able to build f12 images from f18 we need an rpm that has
187 # this patch undone, like we have in place on our f14 boxes (our f14 boxes need a f18-like rpm)
189 YUM="yum --installroot=$INSTALL_ROOT --nogpgcheck -y"
190 echo "$YUM install $FEDORA_PREINSTALLED"
191 $YUM install $FEDORA_PREINSTALLED || { echo "Failed to download rootfs, aborting." ; return 1; }
193 mv "$INSTALL_ROOT" "$cache/rootfs"
194 echo "Download complete."
199 ##############################
200 function fedora_configure() {
205 # disable selinux in fedora
206 mkdir -p $lxc_root/selinux
207 echo 0 > $lxc_root/selinux/enforce
212 cat <<EOF > ${lxc_root}/etc/hostname
217 cat <<EOF > ${lxc_root}/etc/sysconfig/network
219 HOSTNAME=$GUEST_HOSTNAME
222 cat <<EOF > $lxc_root/etc/hosts
223 127.0.0.1 localhost $GUEST_HOSTNAME
228 dev_path="${lxc_root}/dev"
231 mknod -m 666 ${dev_path}/null c 1 3
232 mknod -m 666 ${dev_path}/zero c 1 5
233 mknod -m 666 ${dev_path}/random c 1 8
234 mknod -m 666 ${dev_path}/urandom c 1 9
235 mkdir -m 755 ${dev_path}/pts
236 mkdir -m 1777 ${dev_path}/shm
237 mknod -m 666 ${dev_path}/tty c 5 0
238 mknod -m 666 ${dev_path}/tty0 c 4 0
239 mknod -m 666 ${dev_path}/tty1 c 4 1
240 mknod -m 666 ${dev_path}/tty2 c 4 2
241 mknod -m 666 ${dev_path}/tty3 c 4 3
242 mknod -m 666 ${dev_path}/tty4 c 4 4
243 mknod -m 600 ${dev_path}/console c 5 1
244 mknod -m 666 ${dev_path}/full c 1 7
245 mknod -m 600 ${dev_path}/initctl p
246 mknod -m 666 ${dev_path}/ptmx c 5 2
248 if [ "$(echo $fcdistro | cut -d"f" -f2)" -le "14" ]; then
249 fedora_configure_init
251 fedora_configure_systemd
254 guest_ifcfg=${lxc_root}/etc/sysconfig/network-scripts/ifcfg-$VIF_GUEST
255 ( [ -n "$BUILD_MODE" ] && write_guest_ifcfg_build || write_guest_ifcfg_test ) > $guest_ifcfg
257 [ -z "$IMAGE" ] && fedora_configure_yum $lxc $fcdistro $pldistro
262 function fedora_configure_init() {
265 sed -i 's|.sbin.start_udev||' ${lxc_root}/etc/rc.sysinit
266 sed -i 's|.sbin.start_udev||' ${lxc_root}/etc/rc.d/rc.sysinit
267 # don't mount devpts, for pete's sake
268 sed -i 's/^.*dev.pts.*$/#\0/' ${lxc_root}/etc/rc.sysinit
269 sed -i 's/^.*dev.pts.*$/#\0/' ${lxc_root}/etc/rc.d/rc.sysinit
270 chroot ${lxc_root} chkconfig udev-post off
271 chroot ${lxc_root} chkconfig network on
274 # this code of course is for guests that do run on systemd
275 function fedora_configure_systemd() {
278 # so ignore if we can't find /etc/systemd at all
279 [ -d ${lxc_root}/etc/systemd ] || return 0
280 # otherwise let's proceed
281 ln -sf /lib/systemd/system/multi-user.target ${lxc_root}/etc/systemd/system/default.target
282 touch ${lxc_root}/etc/fstab
283 ln -sf /dev/null ${lxc_root}/etc/systemd/system/udev.service
285 # this was intended for f16 initially, in order to enable getty that otherwise would not start
286 # having a getty running is helpful only if ssh won't start though, and we see a correlation between
287 # VM's that refuse to lxc-stop and VM's that run crazy getty's
288 # so, turning getty off for now instead
289 # #dependency on a device unit fails it specially that we disabled udev
290 # sed -i 's/After=dev-%i.device/After=/' ${lxc_root}/lib/systemd/system/getty\@.service
291 ln -sf /dev/null ${lxc_root}/etc/systemd/system/"getty@.service"
292 rm -f ${lxc_root}/etc/systemd/system/getty.target.wants/*service || :
293 # can't seem to handle this one with systemctl
294 chroot ${lxc_root} chkconfig network on
297 # overwrite container yum config
298 function fedora_configure_yum () {
308 chroot $lxc_root rpm --rebuilddb
310 echo "Initializing yum.repos.d in $lxc"
311 rm -f $lxc_root/etc/yum.repos.d/*
313 cat > $lxc_root/etc/yum.repos.d/building.repo <<EOF
315 name=Fedora $release - $arch
316 baseurl=http://mirror.onelab.eu/fedora/releases/$release/Everything/$arch/os/
320 gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-$release-primary
323 name=Fedora $release - $arch - Updates
324 baseurl=http://mirror.onelab.eu/fedora/updates/$release/$arch/
328 gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-$release-primary
331 # for using vtest-init-lxc.sh as a general-purpose lxc creation wrapper
332 # just mention 'none' as the repo url
333 if [ -n "$REPO_URL" ] ; then
334 if [ ! -d $lxc_root/etc/yum.repos.d ] ; then
335 echo "WARNING : cannot create myplc repo"
337 # exclude kernel from fedora repos
338 yumexclude=$(pl_plcyumexclude $fcdistro $pldistro $DIRNAME)
339 for repo in $lxc_root/etc/yum.repos.d/* ; do
340 [ -f $repo ] && yumconf_exclude $repo "exclude=$yumexclude"
342 # the build repo is not signed at this stage
343 cat > $lxc_root/etc/yum.repos.d/myplc.repo <<EOF
354 ##############################
355 # need to specify the right mirror for debian variants like ubuntu and the like
356 function debian_mirror () {
359 squeeze|wheezy|jessie)
360 echo http://ftp2.fr.debian.org/debian/ ;;
361 oneiric|precise|quantal|raring|saucy)
362 echo http://mir1.ovh.net/ubuntu/ubuntu/ ;;
363 *) echo unknown distro $fcdistro; exit 1;;
367 function debian_install () {
372 arch=$(canonical_arch $personality $fcdistro)
373 mirror=$(debian_mirror $fcdistro)
374 debootstrap --arch $arch $fcdistro $lxc_root $mirror
375 # just like with fedora we ensure a few packages get installed as well
377 #virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "apt-get update"
378 #virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "apt-get -y install $DEBIAN_PREINSTALLED"
379 chroot $lxc_root apt-get update
380 chroot $lxc_root apt-get -y install $DEBIAN_PREINSTALLED
382 cat <<EOF > ${lxc_root}/etc/hostname
388 function debian_configure () {
389 guest_interfaces=${lxc_root}/etc/network/interfaces
390 ( [ -n "$BUILD_MODE" ] && write_guest_interfaces_build || write_guest_interfaces_test ) > $guest_interfaces
393 function write_guest_interfaces_build () {
396 iface $VIF_GUEST inet dhcp
400 function write_guest_interfaces_test () {
403 iface $VIF_GUEST inet static
409 ##############################
410 function setup_lxc() {
414 #trap failure ERR INT
419 personality=$1; shift
421 # create lxc container
423 pkg_method=$(package_method $fcdistro)
426 if [ -z "$IMAGE" ]; then
427 fedora_install || { echo "failed to install fedora root image"; exit 1 ; }
429 fedora_configure || { echo "failed to configure fedora for a container"; exit 1 ; }
432 if [ -z "$IMAGE" ]; then
433 debian_install $lxc || { echo "failed to install debian/ubuntu root image"; exit 1 ; }
435 debian_configure || { echo "failed to configure debian/ubuntu for a container"; exit 1 ; }
438 echo "$COMMAND:: unknown package_method - exiting"
443 # Enable cgroup -- xxx -- is this really useful ?
444 [ -d $lxc_root/cgroup ] || mkdir $lxc_root/cgroup
447 cp /etc/resolv.conf $lxc_root/etc/resolv.conf
448 # and /etc/hosts for at least localhost
449 [ -f $lxc_root/etc/hosts ] || echo "127.0.0.1 localhost localhost.localdomain" > $lxc_root/etc/hosts
451 # grant ssh access from host to guest
452 mkdir -p $lxc_root/root/.ssh
453 cat /root/.ssh/id_rsa.pub >> $lxc_root/root/.ssh/authorized_keys
454 chmod 700 $lxc_root/root/.ssh
455 chmod 600 $lxc_root/root/.ssh/authorized_keys
457 # don't keep the input xml, this can be retrieved at all times with virsh dumpxml
458 config_xml=/tmp/$lxc.xml
459 ( [ -n "$BUILD_MODE" ] && write_lxc_xml_build $lxc || write_lxc_xml_test $lxc ) > $config_xml
461 # define lxc container for libvirt
462 virsh -c lxc:/// define $config_xml
467 function write_lxc_xml_test () {
472 <memory>$MEMORY</memory>
474 <type arch='$arch2'>exe</type>
475 <init>/sbin/init</init>
481 <clock offset='utc'/>
482 <on_poweroff>destroy</on_poweroff>
483 <on_reboot>restart</on_reboot>
484 <on_crash>destroy</on_crash>
486 <emulator>/usr/libexec/libvirt_lxc</emulator>
487 <filesystem type='mount'>
488 <source dir='$lxc_root'/>
491 <interface type="bridge">
492 <source bridge="$PUBLIC_BRIDGE"/>
493 <target dev='$VIF_HOST'/>
495 <console type='pty' />
498 <name>host-bridge</name>
499 <forward mode="bridge"/>
500 <bridge name="$PUBLIC_BRIDGE"/>
506 function write_lxc_xml_build () {
511 <memory>$MEMORY</memory>
513 <type arch='$arch2'>exe</type>
514 <init>/sbin/init</init>
520 <clock offset='utc'/>
521 <on_poweroff>destroy</on_poweroff>
522 <on_reboot>restart</on_reboot>
523 <on_crash>destroy</on_crash>
525 <emulator>/usr/libexec/libvirt_lxc</emulator>
526 <filesystem type='mount'>
527 <source dir='$lxc_root'/>
530 <interface type="network">
531 <source network="default"/>
533 <console type='pty' />
539 # this one is dhcp-based
540 function write_guest_ifcfg_build () {
551 # use fixed GUEST_IP as specified by GUEST_HOSTNAME
552 function write_guest_ifcfg_test () {
557 HOSTNAME=$GUEST_HOSTNAME
567 function devel_or_vtest_tools () {
576 personality=$1; shift
578 pkg_method=$(package_method $fcdistro)
580 pkgsfile=$(pl_locateDistroFile $DIRNAME $pldistro $PREINSTALLED)
582 ### install individual packages, then groups
583 # get target arch - use uname -i here (we want either x86_64 or i386)
585 lxc_arch=$(chroot $lxc_root uname -i)
586 # on debian systems we get arch through the 'arch' command
587 [ "$lxc_arch" = "unknown" ] && lxc_arch=$(chroot $lxc_root arch)
589 packages=$(pl_getPackages -a $lxc_arch $fcdistro $pldistro $pkgsfile)
590 groups=$(pl_getGroups -a $lxc_arch $fcdistro $pldistro $pkgsfile)
592 case "$pkg_method" in
594 [ -n "$packages" ] && chroot $lxc_root yum -y install $packages
595 for group_plus in $groups; do
596 group=$(echo $group_plus | sed -e "s,+++, ,g")
597 chroot $lxc_root yum -y groupinstall "$group"
599 # store current rpm list in /init-lxc.rpms in case we need to check the contents
600 chroot $lxc_root rpm -aq > $lxc_root/init-lxc.rpms
604 if grep -iq ubuntu /vservers/$lxc/etc/lsb-release 2> /dev/null; then
605 # on ubuntu, at this point we end up with a single feed in /etc/apt/sources.list
606 # we need at least to add the 'universe' feed for python-rpm
607 ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e s,main,universe, > sources.list.d/universe.list )
608 # also adding a link to updates sounds about right
609 ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e 's, main,-updates main,' > sources.list.d/updates.list )
610 # tell apt about the changes
611 chroot /vservers/$lxc apt-get update
613 for package in $packages ; do
614 # container not started yet
615 #virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "apt-get install -y $package" || :
616 chroot $lxc_root apt-get install -y $package || :
618 ### xxx todo install groups with apt..
621 echo "unknown pkg_method $pkg_method"
628 function post_install () {
630 personality=$1; shift
631 if [ -n "$BUILD_MODE" ] ; then
632 post_install_build $lxc $personality
633 virsh -c lxc:/// start $lxc
634 # manually run dhclient in guest - somehow this network won't start on its own
635 virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "dhclient $VIF_GUEST"
637 post_install_myplc $lxc $personality
638 virsh -c lxc:/// start $lxc
639 # it sounds like we don't need ssh per se any more
640 # it still makes sense to wait for network readiness though
644 # setup localtime from the host
645 cp /etc/localtime $lxc_root/etc/localtime
648 function post_install_build () {
655 personality=$1; shift
657 ### From myplc-devel-native.spec
658 # be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
659 cat << EOF | chroot $lxc_root bash -x
661 # customize root's prompt
662 /bin/cat << PROFILE > /root/.profile
663 export PS1="[$lxc] \\w # "
670 function post_install_myplc () {
676 personality=$1; shift
678 # be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
679 cat << EOF | chroot $lxc_root bash -x
681 # create /etc/sysconfig/network if missing
682 [ -f /etc/sysconfig/network ] || /bin/echo NETWORKING=yes > /etc/sysconfig/network
684 # turn off regular crond, as plc invokes plc_crond
685 /sbin/chkconfig crond off
687 # customize root's prompt
688 /bin/cat << PROFILE > /root/.profile
689 export PS1="[$lxc] \\w # "
695 function wait_for_ssh () {
698 #trap failure ERR INT
702 echo network in guest is up, waiting for ssh...
704 #wait max 2 min for sshd to start
706 current_time=$(date +%s)
707 stop_time=$(($current_time + 120))
710 while [ "$current_time" -lt "$stop_time" ] ; do
711 echo "$counter-th attempt to reach sshd in container $lxc ..."
712 ssh -o "StrictHostKeyChecking no" $GUEST_IP 'uname -i' && { ssh_up=true; echo "SSHD in container $lxc is UP"; break ; } || :
714 current_time=$(($current_time + 10))
715 counter=$(($counter+1))
718 # Thierry: this is fatal, let's just exit with a failure here
719 [ -z $ssh_up ] && { echo "SSHD in container $lxc is not running" ; exit 1 ; }
724 function failure () {
725 echo "$COMMAND : Bailing out"
731 echo "Usage: $COMMAND [options] lxc-name (aka build mode)"
732 echo "Usage: $COMMAND -n hostname [options] lxc-name (aka test mode)"
734 echo " This command creates a fresh lxc instance, for building, or running a test myplc"
735 echo "In its first form, spawned VM gets a private IP bridged with virbr0 over dhcp/nat"
736 echo "With the second form, spawned VM gets a public IP bridged on public bridge br0"
738 echo "Supported options"
739 echo " -n hostname - the hostname to use in container"
740 echo " -f fcdistro - for creating the root filesystem - defaults to $DEFAULT_FCDISTRO"
741 echo " -d pldistro - defaults to $DEFAULT_PLDISTRO - current support for fedoras debians ubuntus"
742 echo " -p personality - defaults to $DEFAULT_PERSONALITY"
743 echo " -r repo-url - used to populate yum.repos.d - required in test mode"
744 echo " -P pkgs_file - defines a set of extra packages to install in guest"
745 echo " by default we use devel.pkgs (build mode) or runtime.pkgs (test mode)"
746 echo " -i image - the location of the rootfs"
747 echo " -m memory - the amount of allocated memory in MB - defaults to $DEFAULT_MEMORY MB"
748 echo " -v be verbose"
756 #trap failure ERR INT
758 if [ "$(id -u)" != "0" ]; then
759 echo "This script should be run as 'root'"
763 while getopts "n:f:d:p:r:P:i:m:v" opt ; do
765 n) GUEST_HOSTNAME=$OPTARG;;
766 f) fcdistro=$OPTARG;;
767 d) pldistro=$OPTARG;;
768 p) personality=$OPTARG;;
769 r) REPO_URL=$OPTARG;;
770 P) PREINSTALLED=$OPTARG;;
773 v) VERBOSE=true; set -x;;
778 shift $(($OPTIND - 1))
780 # parse fixed arguments
781 [[ -z "$@" ]] && usage
783 lxc_root=/vservers/$lxc
786 almost_empty $lxc_root || \
787 { echo "container $lxc already exists in $lxc_root - exiting" ; exit 1 ; }
788 virsh -c lxc:/// domuuid $lxc >& /dev/null && \
789 { echo "container $lxc already exists in libvirt - exiting" ; exit 1 ; }
792 # if IMAGE, copy the provided rootfs to lxc_root
793 if [ -n "$IMAGE" ] ; then
794 [ ! -d "$IMAGE" ] && \
795 { echo "$IMAGE rootfs folder does not exist - exiting" ; exit 1 ; }
796 rsync -a $IMAGE/ $lxc_root/
800 # check we've exhausted the arguments
801 [[ -n "$@" ]] && usage
803 # BUILD_MODE is true unless we specified a hostname
804 [ -n "$GUEST_HOSTNAME" ] || BUILD_MODE=true
807 [ -z "$fcdistro" ] && fcdistro=$DEFAULT_FCDISTRO
808 [ -z "$pldistro" ] && pldistro=$DEFAULT_PLDISTRO
809 [ -z "$personality" ] && personality=$DEFAULT_PERSONALITY
810 [ -z "$MEMORY" ] && MEMORY=$DEFAULT_MEMORY
813 MEMORY=$(($MEMORY * 1024))
815 # the set of preinstalled packages - depends on mode
816 if [ -z "$PREINSTALLED"] ; then
817 if [ -n "$BUILD_MODE" ] ; then
818 PREINSTALLED=devel.pkgs
820 PREINSTALLED=runtime.pkgs
824 if [ -n "$BUILD_MODE" ] ; then
825 # we can now set GUEST_HOSTNAME safely
826 [ -z "$GUEST_HOSTNAME" ] && GUEST_HOSTNAME=$(echo $lxc | sed -e 's,\.,-,g')
828 # as this command can be used in other contexts, not specifying
829 # a repo is considered a warning
830 # use -r none to get rid of this warning
831 if [ "$REPO_URL" == "none" ] ; then
833 elif [ -z "$REPO_URL" ] ; then
834 echo "WARNING -- setting up a yum repo is recommended"
839 release=$(echo $fcdistro | cut -df -f2)
841 if [ "$personality" == "linux32" ]; then
844 elif [ "$personality" == "linux64" ]; then
848 echo "Unknown personality: $personality"
851 # compute networking details for the test mode
852 # (build mode relies entirely on dhcp on the private subnet)
853 if [ -z "$BUILD_MODE" ] ; then
855 #create_bridge_if_needed $PUBLIC_BRIDGE
856 lbuild-bridge.sh $PUBLIC_BRIDGE
858 GUEST_IP=$(gethostbyname $GUEST_HOSTNAME)
859 # use same NETMASK as bridge interface br0
860 masklen=$(ip addr show $PUBLIC_BRIDGE | grep -v inet6 | grep inet | awk '{print $2;}' | cut -d/ -f2)
861 NETMASK=$(masklen_to_netmask $masklen)
862 GATEWAY=$(ip route show | grep default | awk '{print $3}' | head -1)
863 VIF_HOST="vif$(echo $GUEST_HOSTNAME | cut -d. -f1)"
866 setup_lxc $lxc $fcdistro $pldistro $personality
868 devel_or_vtest_tools $lxc $fcdistro $pldistro $personality
870 # container gets started here
871 post_install $lxc $personality