10 # pkgs parsing utilities
11 PATH=$(dirname $0):$PATH export PATH
15 DEFAULT_PLDISTRO=planetlab
16 DEFAULT_PERSONALITY=linux64
19 COMMAND_VBUILD="vbuild-init-lxc.sh"
20 COMMAND_MYPLC="vtest-init-lxc.sh"
22 lxc_version="0.8.0-rc2"
24 function bridge_init () {
32 # Default Value for INTERFACE_LAN
33 INTERFACE_LAN=$(netstat -rn | grep '^0.0.0.0' | awk '{print $8;}')
36 echo "========== $COMMAND: entering start - beg"
41 echo "========== $COMMAND: entering start - end"
43 # disable netfilter calls for bridge interface (they cause panick on 2.6.35 anyway)
45 # another option would be to accept the all forward packages for
46 # bridged interface like: -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT
47 sysctl net.bridge.bridge-nf-call-iptables=0
48 sysctl net.bridge.bridge-nf-call-ip6tables=0
49 sysctl net.bridge.bridge-nf-call-arptables=0
51 # take extra arg for ifname, if provided
52 [ -n "$1" ] && { INTERFACE_LAN=$1; shift ; }
54 #if we have already configured the same host_box no need to do it again
55 /sbin/ifconfig $INTERFACE_BRIDGE &> /dev/null && {
56 echo "Bridge interface $INTERFACE_BRIDGE already set up - $COMMAND start exiting"
59 /sbin/ifconfig $INTERFACE_LAN &>/dev/null || {
60 echo "Cannot use interface $INTERFACE_LAN - exiting"
65 #Getting host IP/masklen
66 address=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}')
67 [ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; }
69 broadcast=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}')
70 [ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN"
72 gateway=$(netstat -rn | grep '^0.0.0.0' | awk '{print $2;}')
73 [ -z "$gateway" ] && echo "WARNING: Could not determine gateway IP"
76 echo "Creating bridge INTERFACE_BRIDGE=$INTERFACE_BRIDGE"
77 brctl addbr $INTERFACE_BRIDGE
78 #brctl stp $INTERFACE_BRIDGE yes
79 brctl addif $INTERFACE_BRIDGE $INTERFACE_LAN
80 echo "Activating promiscuous mode INTERFACE_LAN=$INTERFACE_LAN"
81 /sbin/ifconfig $INTERFACE_LAN 0.0.0.0 promisc up
83 echo "Setting bridge address=$address broadcast=$broadcast"
85 #/sbin/ifconfig $INTERFACE_BRIDGE $address broadcast $broadcast up
86 dhclient $INTERFACE_BRIDGE
89 #Reconfigure the routing table
90 echo "Configuring gateway=$gateway"
91 route add default gw $gateway
93 echo "========== $COMMAND: exiting start - beg"
96 echo "========== $COMMAND: exiting start - end"
104 function failure () {
105 echo "$COMMAND : Bailing out"
109 function cidr_notation () {
113 for i in $(seq 1 4) ; do
114 part=$(echo $netmask | cut -d. -f $i)
116 "255") cidr=$((cidr + 8));;
117 "254") cidr=$((cidr + 7));;
118 "252") cidr=$((cidr + 6));;
119 "248") cidr=$((cidr + 5));;
120 "240") cidr=$((cidr + 4));;
121 "224") cidr=$((cidr + 3));;
122 "192") cidr=$((cidr + 2));;
123 "128") cidr=$((cidr + 1));;
124 "0") cidr=$((cidr + 0));;
131 function check_yum_installed () {
133 rpm -q $package >& /dev/null || yum -y install $package
136 function check_yumgroup_installed () {
138 yum grouplist "$group" | grep -q Installed || { yum -y groupinstall "$group" ; }
141 function prepare_host() {
143 #################### lxc-tools : rebuild as current fedora release has flaws
144 #install development tools
145 check_yumgroup_installed "Development Tools"
146 #install libcap-devel, libvirt
147 check_yum_installed libcap-devel
148 check_yum_installed libvirt
150 #retrieve and install lxc from sources
151 raw_version=$(lxc-version ||: )
152 lxc_installed_version=$(echo $raw_version | sed -e 's,.*: ,,')
153 if [ "$lxc_installed_version" != "$lxc_version" ] ; then
154 echo "Expecting version" '['$lxc_version']'
155 echo "Found version" '['$lxc_installed_version']'
156 echo "Installing lxc ..."
158 [ -d lxc ] || git clone git://lxc.git.sourceforge.net/gitroot/lxc/lxc
161 git checkout $lxc_version
163 ./configure --prefix=/usr --exec-prefix=/usr
166 mkdir -p /usr/var/lib/
167 [ -d /usr/var/lib/lxc ] || ln -s /var/lib/lxc /usr/var/lib/lxc
171 # #create a placeholder (just a hack to make lxc works)
172 # [ -d "/usr/local/var/lib" ] || mkdir -p /usr/local/var/lib
174 #################### bride initialization
175 check_yum_installed bridge-utils
177 isInstalled=$(netstat -rn | grep '^0.0.0.0' | awk '{print $8;}')
178 if [ "$isInstalled" != "br0" ] ; then
188 function configure_fedora() {
190 # disable selinux in fedora
191 mkdir -p $rootfs_path/selinux
192 echo 0 > $rootfs_path/selinux/enforce
194 # configure the network
196 cat <<EOF > ${rootfs_path}/etc/sysconfig/network-scripts/ifcfg-$IFNAME
210 cat <<EOF > ${rootfs_path}/etc/sysconfig/network
216 # cat <<EOF > $rootfs_path/etc/hosts
217 #127.0.0.1 localhost $HOSTNAME
220 dev_path="${rootfs_path}/dev"
223 mknod -m 666 ${dev_path}/null c 1 3
224 mknod -m 666 ${dev_path}/zero c 1 5
225 mknod -m 666 ${dev_path}/random c 1 8
226 mknod -m 666 ${dev_path}/urandom c 1 9
227 mkdir -m 755 ${dev_path}/pts
228 mkdir -m 1777 ${dev_path}/shm
229 mknod -m 666 ${dev_path}/tty c 5 0
230 mknod -m 666 ${dev_path}/tty0 c 4 0
231 mknod -m 666 ${dev_path}/tty1 c 4 1
232 mknod -m 666 ${dev_path}/tty2 c 4 2
233 mknod -m 666 ${dev_path}/tty3 c 4 3
234 mknod -m 666 ${dev_path}/tty4 c 4 4
235 mknod -m 600 ${dev_path}/console c 5 1
236 mknod -m 666 ${dev_path}/full c 1 7
237 mknod -m 600 ${dev_path}/initctl p
238 mknod -m 666 ${dev_path}/ptmx c 5 2
240 #echo "setting root passwd to $root_password"
241 #echo "root:$root_password" | chroot $rootfs_path chpasswd
247 function configure_fedora_init() {
249 sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit
250 sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit
251 chroot ${rootfs_path} chkconfig udev-post off
252 chroot ${rootfs_path} chkconfig network on
256 function configure_fedora_systemd() {
258 unlink ${rootfs_path}/etc/systemd/system/default.target
259 touch ${rootfs_path}/etc/fstab
260 chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service
261 chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
262 #dependency on a device unit fails it specially that we disabled udev
263 sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service
264 chroot ${rootfs_path} chkconfig network on
267 function download_fedora() {
269 # check the mini fedora was not already downloaded
270 INSTALL_ROOT=$cache/partial
272 mkdir -p $INSTALL_ROOT
273 if [ $? -ne 0 ]; then
274 echo "Failed to create '$INSTALL_ROOT' directory"
278 # download a mini fedora into a cache
279 echo "Downloading fedora minimal ..."
280 YUM="yum --installroot $INSTALL_ROOT -y --nogpgcheck --releasever=$release"
281 PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils openssh-server openssh-clients"
284 MIRROR_URL=http://mirror.onelab.eu/fedora/releases/$release/Everything/$arch/os
285 RELEASE_URL="$MIRROR_URL/Packages/fedora-release-$release-1.noarch.rpm"
286 echo "Fetching from $RELEASE_URL"
287 curl -f "$RELEASE_URL" > $INSTALL_ROOT/fedora-release-$release.noarch.rpm
289 mkdir -p $INSTALL_ROOT/var/lib/rpm
290 rpm --root $INSTALL_ROOT --initdb
291 rpm --root $INSTALL_ROOT -ivh $INSTALL_ROOT/fedora-release-$release.noarch.rpm
292 echo "$YUM install $PKG_LIST"
293 $YUM install $PKG_LIST
295 if [ $? -ne 0 ]; then
296 echo "Failed to download the rootfs, aborting."
300 mv "$INSTALL_ROOT" "$cache/rootfs"
301 echo "Download complete."
307 function copy_fedora() {
309 # make a local copy of the minifedora
310 echo -n "Copying rootfs to $rootfs_path ..."
311 mkdir -p $rootfs_path
312 rsync -a $cache/rootfs/ $rootfs_path/
317 function update_fedora() {
319 YUM="yum --installroot $cache/rootfs -y --nogpgcheck"
324 function install_fedora() {
327 mkdir -p /var/lock/subsys/
330 if [ $? -ne 0 ]; then
331 echo "Cache repository is busy."
335 echo "Checking cache download in $cache/rootfs ... "
336 if [ ! -e "$cache/rootfs" ]; then
338 if [ $? -ne 0 ]; then
339 echo "Failed to download 'fedora base'"
343 echo "Cache found. Updating..."
345 if [ $? -ne 0 ]; then
346 echo "Failed to update 'fedora base', continuing with last known good cache"
348 echo "Update finished"
352 echo "Copy $cache/rootfs to $rootfs_path ... "
354 if [ $? -ne 0 ]; then
355 echo "Failed to copy rootfs"
361 ) 200>/var/lock/subsys/lxc
367 function copy_configuration() {
369 mkdir -p $config_path
370 cat <<EOF >> $config_path/config
375 lxc.rootfs = $rootfs_path
376 lxc.mount = $config_path/fstab
378 lxc.network.type = $lxc_network_type
379 lxc.network.flags = up
380 lxc.network.link = $lxc_network_link
381 lxc.network.name = $IFNAME
382 lxc.network.mtu = 1500
383 lxc.network.ipv4 = $IP/$CIDR
384 lxc.network.veth.pair = $veth_pair
386 #lxc.cgroup.devices.deny = a
388 lxc.cgroup.devices.allow = c 1:3 rwm
389 lxc.cgroup.devices.allow = c 1:5 rwm
391 lxc.cgroup.devices.allow = c 5:1 rwm
392 lxc.cgroup.devices.allow = c 5:0 rwm
393 lxc.cgroup.devices.allow = c 4:0 rwm
394 lxc.cgroup.devices.allow = c 4:1 rwm
396 lxc.cgroup.devices.allow = c 1:9 rwm
397 lxc.cgroup.devices.allow = c 1:8 rwm
398 lxc.cgroup.devices.allow = c 136:* rwm
399 lxc.cgroup.devices.allow = c 5:2 rwm
401 lxc.cgroup.devices.allow = c 254:0 rwm
402 lxc.cgroup.devices.allow = b 255:0 rwm
407 cat <<EOF > $config_path/fstab
408 proc $rootfs_path/proc proc nodev,noexec,nosuid 0 0
409 devpts $rootfs_path/dev/pts devpts defaults 0 0
410 sysfs $rootfs_path/sys sysfs defaults 0 0
412 if [ $? -ne 0 ]; then
413 echo "Failed to add configuration"
423 # overwrite lxc's internal yum config
424 function configure_yum_in_lxc () {
433 echo "Initializing yum.repos.d in $lxc"
434 rm -f $rootfs_path/etc/yum.repos.d/*
436 cat > $rootfs_path/etc/yum.repos.d/building.repo <<EOF
438 name=Fedora $release - \$basearch
439 baseurl=http://mirror.onelab.eu/fedora/releases/$release/Everything/\$basearch/os/
443 gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-$release-primary
446 name=Fedora $release - \$basearch - Updates
447 baseurl=http://mirror.onelab.eu/fedora/updates/$release/\$basearch/
451 gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-$release-primary
454 # for using vtest-init-lxc.sh as a general-purpose lxc creation wrapper
455 # just mention 'none' as the repo url
456 if [ -n "$MYPLC_MODE" -a "$REPO_URL" != "none" ] ; then
457 if [ ! -d $rootfs_path/etc/yum.repos.d ] ; then
458 echo "WARNING : cannot create myplc repo"
460 # exclude kernel from fedora repos
461 yumexclude=$(pl_plcyumexclude $fcdistro $pldistro $DIRNAME)
462 for repo in $rootfs_path/etc/yum.repos.d/* ; do
463 [ -f $repo ] && yumconf_exclude $repo "exclude=$yumexclude"
465 # the build repo is not signed at this stage
466 cat > $rootfs_path/etc/yum.repos.d/myplc.repo <<EOF
477 # return yum or debootstrap
478 function package_method () {
481 f[0-9]*|centos[0-9]*|sl[0-9]*) echo yum ;;
482 lenny|etch) echo debootstrap ;;
483 *) echo Unknown distro $fcdistro ;;
487 # return arch from debian distro and personality
488 function canonical_arch () {
489 personality=$1; shift
491 case $(package_method $fcdistro) in
493 case $personality in *32) echo i386 ;; *64) echo x86_64 ;; *) echo Unknown-arch-1 ;; esac ;;
495 case $personality in *32) echo i386 ;; *64) echo amd64 ;; *) echo Unknown-arch-2 ;; esac ;;
497 echo Unknown-arch-3 ;;
501 # the new test framework creates /timestamp in /vservers/<name> *before* populating it
502 function almost_empty () {
504 # non existing is fine
505 [ ! -d $dir ] && return 0;
506 # need to have at most one file
507 count=$(cd $dir; ls | wc -l); [ $count -le 1 ];
510 function setup_lxc() {
514 #trap failure ERR INT
519 personality=$1; shift
521 # create lxc container
523 if [ $? -ne 0 ]; then
524 echo "failed write configuration file"
529 if [ $? -ne 0 ]; then
530 echo "failed to install fedora"
535 if [ $? -ne 0 ]; then
536 echo "failed to configure fedora for a container"
540 type /bin/systemd >/dev/null 2>&1
541 if [ $? -ne 0 ]; then
542 configure_fedora_init
544 configure_fedora_systemd
548 mkdir $rootfs_path/cgroup
551 cp /etc/resolv.conf $rootfs_path/etc/resolv.conf
552 # and /etc/hosts for at least localhost
553 [ -f $rootfs_path/etc/hosts ] || echo "127.0.0.1 localhost localhost.localdomain" > $rootfs_path/etc/hosts
556 mkdir $rootfs_path/root/.ssh
557 cat /root/.ssh/id_rsa.pub >> $rootfs_path/root/.ssh/authorized_keys
562 lxc-wait -n $lxc -s RUNNING
564 echo $IP is up, waiting for ssh...
566 # wait max 5 min for sshd to start
568 stop_time=$(($(date +%s) + 300))
569 current_time=$(date +%s)
571 while [ "$current_time" -lt "$stop_time" ] ; do
572 echo "ssh attempt ..."
573 ssh -o "StrictHostKeyChecking no" $IP 'uname -i' && { ssh_up=true; echo "SSHD in container $lxc is UP"; break ; } || :
575 current_time=$(($current_time + 10))
578 [ -z $ssh_up ] && echo "SSHD in container $lxc is not running"
582 chroot $rootfs_path rpm --rebuilddb
583 #ssh -o "StrictHostKeyChecking no" $IP "rpm --rebuilddb"
585 configure_yum_in_lxc $lxc $fcdistro $pldistro
590 function devel_or_vtest_tools () {
599 personality=$1; shift
601 pkg_method=$(package_method $fcdistro)
603 # check for .pkgs file based on pldistro
604 if [ -n "$VBUILD_MODE" ] ; then
609 pkgsfile=$(pl_locateDistroFile $DIRNAME $pldistro $pkgsname)
611 ### install individual packages, then groups
612 # get target arch - use uname -i here (we want either x86_64 or i386)
614 lxc_arch=$(chroot $rootfs_path uname -i)
615 # on debian systems we get arch through the 'arch' command
616 [ "$lxc_arch" = "unknown" ] && lxc_arch=$(chroot $rootfs_path arch)
618 packages=$(pl_getPackages -a $lxc_arch $fcdistro $pldistro $pkgsfile)
619 groups=$(pl_getGroups -a $lxc_arch $fcdistro $pldistro $pkgsfile)
621 case "$pkg_method" in
623 [ -n "$packages" ] && chroot $rootfs_path yum -y install $packages
624 for group_plus in $groups; do
625 group=$(echo $group_plus | sed -e "s,+++, ,g")
626 chroot $rootfs_path yum -y groupinstall "$group"
628 # store current rpm list in /init-lxc.rpms in case we need to check the contents
629 chroot $rootfs_path rpm -aq > $rootfs_path/init-lxc.rpms
632 chroot $rootfs_path apt-get update
633 for package in $packages ; do
634 chroot $rootfs_path apt-get install -y $package
636 ### xxx todo install groups with apt..
639 echo "unknown pkg_method $pkg_method"
646 function post_install () {
647 if [ -n "$VBUILD_MODE" ] ; then
648 post_install_vbuild "$@"
650 post_install_myplc "$@"
652 # setup localtime from the host
654 cp /etc/localtime $rootfs_path/etc/localtime
657 function post_install_vbuild () {
664 personality=$1; shift
666 ### From myplc-devel-native.spec
667 # be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
668 cat << EOF | chroot $rootfs_path bash -x
669 # set up /dev/loop* in lxc
670 for i in \$(seq 0 255) ; do
671 mknod -m 640 /dev/loop\$i b 7 \$i
674 # create symlink for /dev/fd
675 [ ! -e "/dev/fd" ] && ln -s /proc/self/fd /dev/fd
677 # modify /etc/rpm/macros to not use /sbin/new-kernel-pkg
678 sed -i 's,/sbin/new-kernel-pkg:,,' /etc/rpm/macros
679 if [ -h "/sbin/new-kernel-pkg" ] ; then
680 filename=\$(readlink -f /sbin/new-kernel-pkg)
681 if [ "\$filename" == "/sbin/true" ] ; then
682 echo "WARNING: /sbin/new-kernel-pkg symlinked to /sbin/true"
683 echo "\tmost likely /etc/rpm/macros has /sbin/new-kernel-pkg declared in _netsharedpath."
684 echo "\tPlease remove /sbin/new-kernel-pkg from _netsharedpath and reintall mkinitrd."
689 # customize root's prompt
690 cat << PROFILE > /root/.profile
691 export PS1="[$lxc] \\w # "
697 # add a "build" user to the system
698 builduser=\$(grep "^build:" /etc/passwd | wc -l)
699 if [ \$builduser -eq 0 ] ; then
700 groupadd -o -g \$gid build;
701 useradd -o -c 'Automated Build' -u \$uid -g \$gid -n -M -s /bin/bash build;
704 # Allow build user to build certain RPMs as root
705 if [ -f /etc/sudoers ] ; then
706 buildsudo=\$(grep "^build.*ALL=(ALL).*NOPASSWD:.*ALL" /etc/sudoers | wc -l)
707 if [ \$buildsudo -eq 0 ] ; then
708 echo "build ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
710 sed -i 's,^Defaults.*requiretty,#Defaults requiretty,' /etc/sudoers
717 function post_install_myplc () {
723 personality=$1; shift
725 # be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
726 cat << EOF | chroot $rootfs_path bash -x
728 # create /etc/sysconfig/network if missing
729 [ -f /etc/sysconfig/network ] || echo NETWORKING=yes > /etc/sysconfig/network
731 # create symlink for /dev/fd
732 [ ! -e "/dev/fd" ] && ln -s /proc/self/fd /dev/fd
734 # turn off regular crond, as plc invokes plc_crond
737 # take care of loginuid in /etc/pam.d
738 sed -i "s,#*\(.*loginuid.*\),#\1," /etc/pam.d/*
740 # customize root's prompt
741 cat << PROFILE > /root/.profile
742 export PS1="[$lxc] \\w # "
750 echo "Usage: $COMMAND_VBUILD [options] lxc-name"
751 echo "Usage: $COMMAND_MYPLC [options] lxc-name repo-url [ -- lxc-options ]"
753 echo " This command creates a fresh lxc instance, for building, or running, myplc"
754 echo "Supported options"
755 echo " -f fcdistro - for creating the root filesystem - defaults to $DEFAULT_FCDISTRO"
756 echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
757 echo " -p personality - defaults to $DEFAULT_PERSONALITY"
758 echo " -i ifname: determines ip and netmask attached to ifname, and passes it to the lxc"
759 echo "-- lxc-options"
760 echo " --netdev : interface to be defined inside lxc"
761 echo " --interface : IP to be defined for the lxc"
762 echo " --hostname : Hostname to be defined for the lxc"
763 echo "With $COMMAND_MYPLC you can give 'none' as the URL, in which case"
764 echo " myplc.repo does not get created"
772 #trap failure ERR INT
787 while getopts "f:d:p:i:" opt ; do
789 f) fcdistro=$OPTARG;;
790 d) pldistro=$OPTARG;;
791 p) personality=$OPTARG;;
797 shift $(($OPTIND - 1))
799 # parse fixed arguments
800 [[ -z "$@" ]] && usage
802 if [ -n "$MYPLC_MODE" ] ; then
803 [[ -z "$@" ]] && usage
807 # parse vserver options
808 if [[ -n "$@" ]] ; then
809 if [ "$1" == "--" ] ; then
817 eval set -- "$LXC_OPTIONS"
822 --netdev) IFNAME=$2; shift 2;;
823 --interface) IP=$2; shift 2;;
824 --hostname) HOSTNAME=$2; shift 2;;
830 if [ -n "$VBUILD_MODE" ] ; then
831 [ -z "$IFNAME" ] && IFNAME=$DEFAULT_IFNAME
832 [ -z "$HOSTNAME" ] && HOSTNAME=$lxc
835 [ -z "$fcdistro" ] && fcdistro=$DEFAULT_FCDISTRO
836 [ -z "$pldistro" ] && pldistro=$DEFAULT_PLDISTRO
837 [ -z "$personality" ] && personality=$DEFAULT_PERSONALITY
839 release=$(echo $fcdistro | cut -df -f2)
841 if [ "$personality" == "linux32" ]; then
844 elif [ "$personality" == "linux64" ]; then
848 echo "Unknown personality: $personality"
851 # need lxc installed before we can run lxc-ls
852 # need bridge installed
855 if [ -n "$VBUILD_MODE" ] ; then
857 # Bridge IP affectation
858 x=$(echo $personality | cut -dx -f2)
859 y=$(echo $fcdistro | cut -df -f2)
863 NETMASK="255.255.255.0"
864 GATEWAY="192.168.122.1"
866 lxc_network_type=veth
867 lxc_network_link=virbr0
869 echo "the IP address of container $lxc is $IP "
871 [[ -z "$REPO_URL" ]] && usage
872 [[ -z "$IP" ]] && usage
873 NETMASK=$(ifconfig br0 | grep 'inet addr' | awk '{print $4}' | sed -e 's/.*://')
874 GATEWAY=$(route -n | grep 'UG' | awk '{print $2}')
875 [[ -z "$HOSTNAME" ]] && usage
876 lxc_network_type=veth
878 veth_pair="i$(echo $HOSTNAME | cut -d. -f1)"
881 CIDR=$(cidr_notation $NETMASK)
884 if [ "$(id -u)" != "0" ]; then
885 echo "This script should be run as 'root'"
890 rootfs_path=$path/$lxc/rootfs
891 config_path=$path/$lxc
892 cache_base=/var/cache/lxc/fedora/$arch
893 cache=$cache_base/$release
896 # check whether the rootfs directory is created to know if the container exists
897 # bacause /var/lib/lxc/$lxc is already created while putting $lxc.timestamp
898 [ -d $rootfs_path ] && { echo "container $lxc already exists - exiting" ; exit 1 ; }
900 setup_lxc $lxc $fcdistro $pldistro $personality
902 devel_or_vtest_tools $lxc $fcdistro $pldistro $personality
904 post_install $lxc $personality