#!/bin/sh
########################################################################
# Begin $rc_base/init.d/fsresize
#
# Description : Resize the root filesystem in the background
#
# Authors     : Arne Fitzenreiter - arne_f@ipfire.org
#
# Version     : 1.01
#
# Notes       :
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

case "${1}" in
	start)
		boot_mesg "Background Autoresize root partition to use the whole drive"
		# Detect device
		ROOT=`mount | grep -m1 " / " | cut -d" " -f1`;
		DRV=${ROOT::`expr length $ROOT`-1}

		boot_mesg "resize ${DRV}3 ..."
		nice -n 19 $0 background ${DRV}3 > /dev/null &
		;;
	background)
		resize2fs -p $2

		# Erase symlink, it should run only once
		rm -f /etc/rc.d/rcsysinit.d/S42fsresize
		sync
		exit 0;

		;;

	*)
		echo "Usage: ${0} {start}"
		exit 1
		;;
esac

# End $rc_base/init.d/26fsresize
