new package lxc-sliceimage
[vserver-reference.git] / initscripts / lxc-sliceimage
1 #!/bin/bash
2 # chkconfig: 345 20 80
3 # description: Create BTRFS subvolumes for LXC reference images.
4 #
5
6
7 case "$1" in
8     start|restart|reload)
9         ;;
10     force)
11         FORCE=true;;
12     stop|status)
13         exit 0
14         ;;
15     *)
16         echo $"Usage: $0 {start|stop|restart|reload|status|force}"
17         exit 1
18         ;;
19 esac
20
21 # Check if we are in the build environment
22 mount | grep -q 'planetlab-vservers' || exit 0
23
24 # Source function library
25 . /etc/init.d/functions
26
27 # xxx get version some other way
28 # might just want to scan /vservers/.vref instead
29 # upgrades (from the real image to the .lvref area) might be challenging
30 # xxx 
31
32 sliceimage_dir=/vservers/.vref
33
34 [ -d $sliceimage_dir ] || exit 0
35
36 sliceimages=$(cd $sliceimage_dir ; ls )
37
38 for sliceimage in $sliceimages; do
39     mkdir -p /vservers/.lvref
40     [ -d /vservers/.lvref/$sliceimage ] && continue
41     btrfs subvolume create /vservers/.lvref/$sliceimage
42 # what is that ?
43 #    btrfs subvolume create /vservers/.lvref/lxc-squeeze-x86_64
44     # copy the slice image into the btrfs ?
45     tar -C $sliceimage_dir -cf - $sliceimage | tar -C /vservers/.lvref -xf -
46 # we need a smarter way to handle upgrades
47 # the original code trashed the ref image that came with an rpm
48 #    rm -rf /vservers/lxc-reference-${VERSION}.tgz
49 # this would probably cause the image to be re-created upon yum update
50 # or prevent updates to make it to the node ?
51 #    rm -rf $sliceimage_dir/$sliceimage
52 fi
53
54 exit 0