#!/bin/sh
#判断进程是否存在，如果不存在就启动它
PIDS=`ps|grep kk_midware |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kk_midware is runing!"
else
	export LD_LIBRARY_PATH=/app/ccuApps/lib
	/app/ccuApps/bin/kk_midware &
#运行进程
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"
	export LD_LIBRARY_PATH=/app/ccuApps/lib
	/app/ccuApps/bin/kk_cloud &
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"
	export LD_LIBRARY_PATH=/app/ccuApps/lib
	/app/ccuApps/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=/app/ccuApps/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
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"
	export LD_LIBRARY_PATH=/app/ccuApps/lib
	/app/ccuApps/bin/kk_lan &
fi
