#! /bin/bash
# postflight script for Yamaha Steinberg USB Driver

echo "postflight script for Yamaha Steinberg USB Driver"

echo "process check start..."

TIMEOUT=300
SLEEP=1


count=0
while [ $count -lt $TIMEOUT ];
do
#	string=`COMMAND_MODE=unix03 ps -ef | grep "kextcache" | grep -v grep`
#	echo "$string"

	isAlive=`COMMAND_MODE=unix03 ps -ef | grep "kextcache" | grep " -m" | grep -v grep | wc -l`
#	echo "kextcache -kext isAlive = $isAlive"

	if [ $isAlive == 0 ]; then
		isAlive=`COMMAND_MODE=unix03 ps -ef | grep "kextcache" | grep " -u" | grep -v grep | wc -l`
#		echo "kextcache -u / isAlive = $isAlive"
	fi

	if [ $isAlive == 0 ]; then
		echo "kextcache is not Alive. break."
		break
	fi
	sleep $SLEEP
	count=`expr $count + $SLEEP`
done
	echo "TIME = $count"
	if [ $count -ge $TIMEOUT ]; then
		echo "kextcache is Alive. TIME OUT."
	fi

echo "process check end..."

echo "Update the standard system repository of kernel extensions."
touch /System/Library/Extensions
