#!/system/bin/sh

TESTVAR=$(getprop init.complete);
if [ "$TESTVAR" = "" ];
then
setprop init.complete 1;

LOG="/system/bin/log -p w complete: ";
$LOG "Start init completion script"

SEQUENCEVAR=$(getprop init.userinit.done);
while [ "$SEQUENCEVAR" = "" ]
do
	$LOG "userinit still running, postponing"
	sleep 1;
	SEQUENCEVAR=$(getprop init.userinit.done);
done

$LOG "Complete init active!"

# scheduled permission fix from EM
if [ -e /data/local/sd-ext.fixperms ];
then
  sync;
  fix_permissions
  busybox rm -f /data/local/sd-ext.fixperms;
  sync;
fi;

sync;
setprop cm.filesystem.ready 1;

setprop init.complete.done 1;
fi;