-echo "* Installing configuration file"
-install -D -m 644 $config $data/etc/planetlab/plc_config.xml
-
-# Move "data" directories out of the installation
-datadirs=(
-/etc/planetlab
-/var/lib/pgsql
-/var/www/html/alpina-logs
-/var/www/html/boot
-/var/www/html/download
-/var/www/html/generated
-/var/www/html/install-rpms
-/var/www/html/xml
-)
-
-echo "* Moving data directories out of the installation"
-mkdir -p $root/data
-for datadir in "${datadirs[@]}" ; do
- mkdir -p ${data}$datadir
- if [ -d $root/$datadir -a ! -h $root/$datadir ] ; then
- (cd $root && find ./$datadir | cpio -p -d -u ../$data/)
- fi
- rm -rf $root/$datadir
- mkdir -p $(dirname $root/$datadir)
- ln -nsf /data$datadir $root/$datadir
-done
-
-# Shrink to 100 MB free space
-kb=$(python <<EOF
-import os
-df = os.statvfs('$root')
-target = 100 * 1024 * 1024 / df.f_bsize
-if df.f_bavail > target:
- print (df.f_blocks - (df.f_bavail - target)) * df.f_bsize / 1024
-EOF
-)
-
-umount $root
-trap - ERR
-
-if [ -n "$kb" ] ; then
- # Setup loopback association. Newer versions of losetup have a -f
- # option which finds an unused loopback device, but we must
- # support FC2 for now.
- # dev_loop=$(losetup -f)
- for i in `seq 1 7` ; do
- if ! grep -q "^/dev/loop$i" /proc/mounts ; then
- dev_loop="/dev/loop$i"
- break
- fi
- done
- losetup $dev_loop $root.img
- trap "losetup -d $dev_loop" ERR
-
- # Resize the filesystem
- echo "* Checking filesystem"
- e2fsck -a -f $dev_loop
- echo "* Shrinking filesystem"
- resize2fs $dev_loop ${kb}K
-
- # Tear down loopback association
- losetup -d $dev_loop
- trap - ERR
-
- # Truncate the image file
- perl -e "truncate '$root.img', $kb*1024"
-fi
-
-# Write sysconfig
-cat >plc.sysconfig <<EOF
-PLC_ROOT=/plc/$root
-PLC_DATA=/plc/$data
-#PLC_OPTIONS="-v"
-EOF
-
-# Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
-# tarball already contains all of the node RPMs pre-installed. Only
-# updates or optional packages should be placed in this directory.
-if [ -n "$RPM_BUILD_DIR" ] ; then
- echo "* Initializing node RPMs directory"
- RPM_RPMS_DIR=$(cd $(dirname $RPM_BUILD_DIR)/RPMS && pwd -P)
- mkdir -p $data/var/www/html/install-rpms/planetlab
- if [ -f $RPM_RPMS_DIR/yumgroups.xml ] ; then
- install -D -m 644 $RPM_RPMS_DIR/yumgroups.xml \
- $data/var/www/html/install-rpms/planetlab/yumgroups.xml
- fi
- # yum-2.0.x
- if [ -x /usr/bin/yum-arch ] ; then
- yum-arch $data/var/www/html/install-rpms/planetlab
- fi
- # yum-2.4.x
- if [ -x /usr/bin/createrepo ] ; then
- if [ -f $data/var/www/html/install-rpms/planetlab/yumgroups.xml ] ; then
- groupfile="-g yumgroups.xml"
- fi
- createrepo $groupfile $data/var/www/html/install-rpms/planetlab
- fi
-fi
-
-# Bootstrap the system for quicker startup (and to populate the
-# PlanetLabConf tables from PLC, which may not be accessible
-# later). The bootstrap.xml configuration overlay configures the web
-# server to run on an alternate port (in case the build machine itself
-# is running a web server on port 80). Start everything up to
-# bootstrap the database, then shut it back down again immediately.
-echo "* Bootstrapping installation"
-
-./plc-config --save $data/etc/planetlab/plc_config.xml bootstrap.xml
-
-# Otherwise, host.init will try to read /etc/sysconfig/plc
-export PLC_ROOT=$PWD/$root
-export PLC_DATA=$PWD/$data
-#export PLC_OPTIONS="-v"
-
-./host.init start
-RETVAL=$?