#!/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)
		if [ -e "/.resizefs" ]; then
			boot_mesg "Re-sizing root partition..."

			# Find root device
			mount | while read -r dev tmp1 mountpoint tmp2; do
				# Skip generic entries
				[ "${dev}" = "rootfs" ] && continue

				if [ "${mountpoint}" = "/" ]; then
					# Resize filesystem
					resize2fs -p "${dev}"

					# Remove marker
					rm -f /.resizefs
					break
				fi
			done
		fi
		;;

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

# End $rc_base/init.d/26fsresize
