#!/bin/bash
IfExistAuth=`ps -Ac -o command|grep -x AuthenMngService`
IfExistMon=`ps -Ac -o command|grep -x iNodeMon`

if [ "$IfExistAuth" != "" -o "$IfExistMon" != "" ]
then
    sudo /Library/StartupItems/iNodeAuthService/iNodeAuthService stop
fi

Sec=0
while [ 1 ]
do
    IfExistMon=`ps -Ac -o command|grep -x iNodeMon`
    if [ "$IfExistMon" != "" ]
    then
        sleep 1
        Sec=`expr $Sec + 1`

        if [ "$Sec" -gt 10 ]
	then
            sudo killall -9 iNodeMon
        fi
    else
        break
    fi
done

Sec=0
while [ 1 ]
do
    IfExistAuth=`ps -Ac -o command|grep -x AuthenMngService`
    if [ "$IfExistAuth" != "" ]
    then
        sleep 1
        Sec=`expr $Sec + 1`

        if [ "$Sec" -gt 10 ]
	then
            sudo killall -9 AuthenMngService
        fi
    else
        break
    fi
done
    
IfExistUI=`ps -Ac -o command|grep -x iNodeClient`
if [ "$IfExistUI" != "" ]
then
    sleep 5
    sudo killall -9 iNodeClient
fi

exit 0
