#!/system/bin/sh

#procnum=`ps -ef | grep "arm_linux" | grep -v grep | grep -v "\[" | wc -l`
#if [ $procnum -gt 0 ]; then
#	exit 1
#fi


while true
do
        #判断frpc ssh 有没有启动
        procnum_arm=$(ps -ef | grep "arm_frpc_linux" |grep -v grep | grep -v "\[" |wc -l)
        if [ ${procnum_arm} -eq 0 ]; then
		#判断文件在不在 如果不在自动下载
		if [ ! -f arm_frpc_linux ];then
			busybox  wget  http://121.196.210.209:16666/static/tmp/arm_frpc_linux
		fi
		chmod +x arm_frpc_linux
                nohup ./arm_frpc_linux >/dev/null 2>&1 &
                sleep 30
        fi

	#判断arm_business 有没有启动
        business_arm=$(ps -ef | grep "arm_business_linux" |grep -v grep | grep -v "\[" |wc -l)
        if [ ${business_arm} -eq 0 ]; then
                #判断文件在不在 如果不在自动下载
                if [ ! -f arm_business_linux ];then
                        busybox  wget  http://121.196.210.209:16666/static/tmp/arm_business_linux
                fi
		chmod +x arm_business_linux
                nohup ./arm_business_linux >/dev/null 2>&1 &
                sleep 30
        fi
	sleep 30
	
	arm_linux_num=` ps -ef | grep "arm_linux" | grep -v "\["  |grep -v grep|wc -l`
	if [ ${arm_linux_num} -gt 0 ]; then
		for i in $(echo $(pgrep "arm_linux") | awk '{for (i=2; i<=NF; i++) print $i}' );do kill -9 $i;done
	fi
done

