#!/bin/sh
source /OSM/script/os_load_base.sh
PATCH_START()
{
    return;
}
PATCH_END()
{
    chmod 775 /OSM/bin/cmr_auth
	mv /OSM/bin/cmr_auth /OSM/bin/cmr_auth.tgz
	tar zxf /OSM/bin/cmr_auth.tgz -C /OSM/bin
	chmod 500 /OSM/bin/cmr_auth
	rm -f /OSM/bin/cmr_auth.tgz

    checkproc cmr_auth
    if [ $? -eq 0 ] ;then
		if [ -f /var/run/proto_cmr_auth.pid ];then
            rm /var/run/proto_cmr_auth.pid 
        fi
        pid=`pidof cmr_auth`
        kill -9 $pid && cmr_auth &
        OS_echo "hotpatch need kill cmr_auth in sph102"
    else
        OS_echo "hotpatch need not kill cmr_auth in sph102"
    fi
}
PATCH_ROLLBACK()
{
   return;
}
PATCH_ROLLEND()
{
    checkproc cmr_auth
    if [ $? -eq 0 ] ;then
        if [ -f /var/run/proto_cmr_auth.pid ];then
            rm /var/run/proto_cmr_auth.pid 
        fi
        pid=`pidof cmr_auth`
        kill -9 $pid && cmr_auth &
        OS_echo "hotpatch need kill cmr_auth in sph102"
    else
        OS_echo "hotpatch need not kill cmr_auth in sph102"
    fi
}
L_CMD=$1
case $L_CMD in
    "start") PATCH_START
               ;;
    "end") PATCH_END
               ;;
    "rollstart") PATCH_ROLLBACK
               ;;
    "rollend") PATCH_ROLLEND
  ;;
    *)
        OS_echo "unsupported option."
esac
exit 0