--- /dev/null
+#
+# Runs once a day to update the VServer reference images and system
+# slice configuration files
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+
+@M@ @H@ * * * root /etc/init.d/lxc-sliceimage start >/dev/null 2>&1
--- /dev/null
+#!/bin/bash
+# chkconfig: 345 20 80
+# description: Create BTRFS subvolumes for LXC reference images.
+#
+
+
+case "$1" in
+ start|restart|reload)
+ ;;
+ force)
+ FORCE=true;;
+ stop|status)
+ exit 0
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|status|force}"
+ exit 1
+ ;;
+esac
+
+# Check if we are in the build environment
+mount | grep -q 'planetlab-vservers' || exit 0
+
+# Source function library
+. /etc/init.d/functions
+
+# xxx get version some other way
+# might just want to scan /vservers/.vref instead
+# upgrades (from the real image to the .lvref area) might be challenging
+# xxx
+
+sliceimage_dir=/vservers/.vref
+
+[ -d $sliceimage_dir ] || exit 0
+
+sliceimages=$(cd $sliceimage_dir ; ls )
+
+for sliceimage in $sliceimages; do
+ mkdir -p /vservers/.lvref
+ [ -d /vservers/.lvref/$sliceimage ] && continue
+ btrfs subvolume create /vservers/.lvref/$sliceimage
+# what is that ?
+# btrfs subvolume create /vservers/.lvref/lxc-squeeze-x86_64
+ # copy the slice image into the btrfs ?
+ tar -C $sliceimage_dir -cf - $sliceimage | tar -C /vservers/.lvref -xf -
+# we need a smarter way to handle upgrades
+# the original code trashed the ref image that came with an rpm
+# rm -rf /vservers/lxc-reference-${VERSION}.tgz
+# this would probably cause the image to be re-created upon yum update
+# or prevent updates to make it to the node ?
+# rm -rf $sliceimage_dir/$sliceimage
+fi
+
+exit 0
--- /dev/null
+/var/log/lxc-sliceimage {
+ copytruncate
+ compress
+ daily
+ notifempty
+ rotate 5
+ missingok
+}
--- /dev/null
+%define name lxc-sliceimage
+%define version 5.1
+%define taglevel 0
+
+%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
+
+Vendor: PlanetLab
+Packager: PlanetLab Central <support@planet-lab.org>
+Distribution: PlanetLab %{plrelease}
+URL: %{SCMURL}
+
+Summary: lxc-specific node code for slice families
+Name: %{name}
+Version: %{version}
+Release: %{release}
+Source0: %{name}-%{version}.tar.bz2
+License: GPL
+Group: Applications/System
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+Requires: btrfs-progs
+BuildArch: noarch
+
+%description
+A simple package to deploy reference images for lxc
+
+%prep
+%setup -q
+
+%build
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -D -m 755 initscripts/lxc-sliceimage ${RPM_BUILD_ROOT}/%{_initrddir}/lxc-sliceimage
+install -D -m 644 cron.d/lxc-sliceimage $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/lxc-sliceimage
+install -D -m 644 logrotate/lxc-sliceimage $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/lxc-sliceimage
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%{_initrddir}/lxc-sliceimage
+%{_sysconfdir}/cron.d/lxc-sliceimage
+%{_sysconfdir}/logrotate.d/lxc-sliceimage
+
+%post
+chkconfig --add lxc-sliceimage
+chkconfig lxc-sliceimage on
+# Randomize daily run time
+M=$((60 * $RANDOM / 32768))
+H=$((24 * $RANDOM / 32768))
+sed -i -e "s/@M@/$M/" -e "s/@H@/$H/" %{_sysconfdir}/cron.d/lxc-sliceimage