#!/bin/sh
#判断进程是否存在，如果不存在就启动它

ccuApps="/app/ccuApps"
restart_process()
{
	$ccuApps/killall.sh
	$ccuApps/onboot.sh
}	
PIDS=`ps|grep kk_midware |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kk_midware is runing!"
else
	restart_process;
#运行进程
fi
sleep 3
PIDS=`ps|grep kk_cloud |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kk_cloud is runing!"
else
	echo "kk_cloud is not running ,now restart kk_midware and kk_cloud"
	restart_process;
fi
sleep 1
PIDS=`ps|grep smarthome_z3gw_nx5 |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "smarthome_z3gw_nx5 is runing!"
else
	echo "smarthome_z3gw_nx5 is not running ,now restart smarthome_z3gw_nx5"
	restart_process;
fi
sleep 1
PIDS=`ps|grep kk_lan |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kk_lan is runing!"
else
	echo "kk_lan is not running ,now restart kk_lan"
	restart_process;
fi
