EdgeGateway_FSU/EdgeGateway_FSU_App/bsh/EdgeGateway_FSU_App_Start.sh

151 lines
5.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/sh
echo "EdgeGateway_FSU_App Start">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Start Record">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
#/dev 创建一个子目录shm后续会在系统中添加 ::sysinit:/bin/mkdir -p /dev/shm inittab文件
#echo "Mkdir /dev/shm">>//home/EdgeGateway_FSU_App/log/Devicestartup.log
#cd /dev
#mkdir shm
#启动先判断相关进程是否打开,如果打开则关闭相关进程
cd /home/EdgeGateway_FSU_App/bsh
./KillAllSubProcess.sh
wait
#增加一个输入判断,防止一直运行无法跳出循环 kooloo add 2024022201
echo "Press any key to continue... except e or E... ?\n"
echo "Press any key to continue... except e or E...">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
Tempi=1
while [ $Tempi -le 2 ]
do
echo $Tempi
let Tempi++ #注意这里如果不改变$i的值会变成死循环
#read Tempstr
read -t 8 Tempstr #8s 内输入 kooloo add 2024022301
echo "Tempstr的值为: $Tempstr ?\n"
if [[ $Tempstr == e ]];then
echo "e break!"
exit
elif [[ $Tempstr == E ]];then
echo "E break!"
exit
fi
#sleep 1
# Tempi=$[$Tempi+1] //两种写法
done
echo "最后Tempi的值为: $Tempi ?\n"
echo "Continuing... ?\n"
#时间校准进程
cd /home/EdgeGateway_FSU_App/App
./TimeAlignedApp
wait
date >>/home/EdgeGateway_FSU_App/log/Devicestartup.log
#判断 MainProcessApp 执行文件 kooloo add 202312
if [ ! -f /home/EdgeGateway_FSU_App/App/MainProcessApp ];then
echo "MainProcessApp not exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record End" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "MainProcessApp not exist"
exit 0
else
echo "MainProcessApp exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record continue" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "MainProcessApp exist"
fi
#判断 DevicePortGetApp 执行文件 kooloo add 202312
if [ ! -f /home/EdgeGateway_FSU_App/App/DevicePortGetApp ];then
echo "DevicePortGetApp not exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record End" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "DevicePortGetApp not exist"
exit 0
else
echo "DevicePortGetApp exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record continue" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "DevicePortGetApp exist"
fi
#判断 MqttClientApp 执行文件 kooloo add 202312
if [ ! -f /home/EdgeGateway_FSU_App/App/MqttClientApp ];then
echo "MqttClientApp not exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record End" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "MqttClientApp not exist"
exit 0
else
echo "MqttClientApp exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record continue" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "MqttClientApp exist"
fi
#判断 TimeAlignedApp 执行文件 kooloo add 202312
if [ ! -f /home/EdgeGateway_FSU_App/App/TimeAlignedApp ];then
echo "TimeAlignedApp not exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record End" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "TimeAlignedApp not exist"
exit 0
else
echo "TimeAlignedApp exist" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "Record continue" >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "TimeAlignedApp exist"
fi
#cd /home/EdgeGateway_FSU_App/App
#./MainProcessApp&
cd /
./home/EdgeGateway_FSU_App/App/MainProcessApp&
#exit 0 2024022701
while [ 1 -eq 1 ] #写一个永远为真的表达式1等于1这个条件永远为真所以这个脚本会一直循环下去
do
PIDSTest=`ps -ef | awk '{print}'`
echo $PIDSTest >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "当前所有PID值,$PIDSTest "
PIDS=`ps -ef |grep MainProcessApp |grep -v grep | awk '{print $1}'`
echo $PIDS >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
if [ "$PIDS" != "" ]; then
echo "MainProcessApp is runing!"
echo "MainProcessApp is runing!">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
else #
echo "MainProcessApp is not runing!"
echo "MainProcessApp is not runing!">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
./home/EdgeGateway_FSU_App/bsh/KillAllSubProcess.sh
wait
echo "MainProcessApp Reboot!"
echo "MainProcessApp Reboot!">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
./home/EdgeGateway_FSU_App/App/MainProcessApp&
#运行进程
fi
#判断log文件大小 如果超过一定值 则将其清空
file_size=$(stat -c %s "/home/EdgeGateway_FSU_App/log/Devicestartup.log")
if [ $file_size -gt 10000000 ]; then
echo "文件太大,需要清空,$file_size "
" " >/home/EdgeGateway_FSU_App/log/Devicestartup.log
else
echo "文件大小不为0"
fi
date
Tempj=1
while [ $Tempj -le 5 ]
do
let Tempj++ #注意这里如果不改变$i的值会变成死循环
sleep 1
echo 0 > /sys/class/leds/Dbg-led0/brightness
sleep 1
echo 1 > /sys/class/leds/Dbg-led0/brightness
done
done
echo "end"
#test use kooloo add 202312
#cd /home/EdgeGateway_FSU_App/App