#!/bin/bash
#
# KM setup 2nd
#

case "$1" in
  start)
	echo "KM setup 2nd: Start"
	# Mount all devices
	echo "KM setup 2nd: Mounting local filesystems"

	# !! Infomation !!
    # It waits for a maximum of 3 seconds per device file
    # until the device file indicated to fstab is created, 
    # since device file creation may take time in USB memory booting. 
	for args in `grep /dev /etc/fstab`
	do
	  case $args in
	    /dev*)
		  timeout_count=0
		  until [ -e ${args} ]
		  do
			sleep 1
			timeout_count=`expr $timeout_count + 1`
			if [ ${timeout_count} -ge 3 ]; then
			  break
			fi
		  done
		  ;;
		*)
		  ;;
	  esac
	done

	mount -a

	echo "KM setup 2nd: Setup logging"
	dmesg 2>/dev/null > /var/log/dmesg 
	touch /var/log/wtmp 2>/dev/null
	echo "KM setup 2nd: Done"
	;;
  *)
	;;
esac

exit $?
