#!/bin/bash # chkconfig: 345 20 80 # description: Create BTRFS subvolumes for LXC reference images. # # not needed -- Source function library #. /etc/init.d/functions # This is where sliceimage(s) store their reference images sliceimage_dir=/vservers/.vref lxc_dir=/vservers/.lvref # Check if we are in the build environment function check_node () { mount | grep -q 'planetlab-vservers' || exit 0 [ -d $sliceimage_dir ] || { echo "No sliceimage installed" ; exit 1; } } function start () { check_node mkdir -p $lxc_dir slicefamilies=$(cd $sliceimage_dir ; ls ) for slicefamily in $slicefamilies; do # initialize if needed [ -d $lxc_dir/$slicefamily ] || btrfs subvolume create $lxc_dir/$slicefamily # xxx what is that ? #btrfs subvolume create $lxc_dir/lxc-squeeze-x86_64 # copy the slice image into the btrfs ? rsync -av --delete $sliceimage_dir/$slicefamily/ $lxc_dir/$slicefamily/ done } function status () { echo -n "Checking node .. " check_node echo OK echo "From installed sliceimage variants" ls $sliceimage_dir echo "Exported to lxc" ls $lxc_dir } case "$1" in start|restart|reload) start ; exit 0 ;; status) status ; exit 0 ;; stop) exit 0 ;; *) echo $"Usage: $0 {start|stop|status}" exit 1 ;; esac