first commit: some shell scripts

This commit is contained in:
TangChao
2022-08-22 08:38:59 +00:00
commit 5937333be7
8 changed files with 126 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Logs/

0
autoMount.sh Executable file
View File

83
finger_daemon.sh Executable file
View File

@ -0,0 +1,83 @@
#!/bin/bash
# Program:
# This script is a finger daemon of program ximeaImageRecorder and psdkProgram. It has three function:
# 1) ensure that the programs ximeaImagerRecorder and psdkProgram are runing; if not run the programs;
# 2) generate log file name based the local time and directory if not exist;
# 3) redirect the output of programs to file generated in (2);
# Usage:
# 1) crontab -e
# 2) */1 * * * * ~/tc_scripts/finger_daemon.sh
# History:
# 2021/07/13 Tangchao First release
# 2022/06/24 Tangchao Second release
#
sleep 60s #rockpi need sleep 180s when start because if not wired lan which psdk's image transmission use don't work normal.
echo "the current directory is " $(pwd)
if [ ! -e /home/rock/programRunLog ]; then
mkdir /home/rock/programRunLog
else
echo directory "~/programRunLog" exist!
fi
cd /home/rock/programRunLog
echo "the current directory is " $(pwd)
# run psdk program
if [ ! -e djiLog ]; then
mkdir djiLog
else
echo directory "djiLog" exist!
fi
#echo "1111111111111111111111111111111111"
#sleep 60s
#echo "2222222222222222222222222222222222"
bool=`ps -ef | grep psdk_demo | grep -v grep | wc -l`
if [ $bool -eq 0 ] ; then
psdkLogFileName=$(date +%Y%m%d_%H%M_%S).dji_log
sudo /bin/echo $(/bin/date +%F_%T) >> /home/rock/programRunLog/djiLog/runtime.log
sudo /home/rock/tc_projects/Payload_SDK_V2.2.1_300tc/sample/platform/linux/manifold2/project/build/psdk_demo &> djiLog/$psdkLogFileName &
echo "Now, start run dji program!"
else
echo "Dji program already runing!"
fi
# run ximea program
if [ ! -e hyperspectralLog ]; then
mkdir hyperspectralLog
else
echo directory "hyperspectralLog" exist!
fi
procnum=`ps -ef | grep ximeaImageRecorder | grep -v grep | wc -l`
if [ $procnum -eq 0 ] ; then
fileName=$(date +%Y%m%d_%H%M_%S).hyperspectral_log
echo $fileName
sudo /home/rock/tc_projects/ximeaImageRecorder/build/ximeaImageRecorder &> hyperspectralLog/$fileName &
echo "Now, start run hyperspectral program!"
else
echo "HyperspectralLog program already runing!"
fi

21
finger_daemon_while.sh Executable file
View File

@ -0,0 +1,21 @@
#! /bin/sh
PRO_NAME=psdk_demo
while true ; do
NUM=`ps -ef | grep ${PRO_NAME} | grep -v grep |wc -l`
# echo $NUM
if [ "${NUM}" -lt "1" ];then
echo "${PRO_NAME} was killed"
/bin/echo $(/bin/date +%F_%T) >> /home/rock/programRunLog/djiLog/runtime.log
psdkLogFileName=$(date +%Y%m%d_%H%M_%S).dji_log
sudo /home/rock/tc_projects/Payload_SDK_V2.2.1/sample/platform/linux/manifold2/project/build/psdk_demo &> /home/rock/programRunLog/djiLog/$psdkLogFileName
elif [ "${NUM}" -gt "1" ];then
echo "${PRO_NAME} is running"
fi
done
exit 0

2
kill_psdk.sh Executable file
View File

@ -0,0 +1,2 @@
sleep 300s
ps -ef | grep psdk | grep -v grep | awk '{print $2}' | sudo xargs kill -9

12
kill_psdk_v2.sh Executable file
View File

@ -0,0 +1,12 @@
#! /bin/bash
psdkpid=$(ps -ef | grep psdk_demo | grep -v grep | awk '{print $2}')
while true ; do
if [ $psdkpid -le 5000 ]; then
#sleep 100s
sudo kill $psdkpid
#echo $psdkpid 'xiaoyu 5000'
fi
done
exit 0

4
usbadd.sh Executable file
View File

@ -0,0 +1,4 @@
touch ~/mount.log
# sudo mount /dev/sda1 /media/usb &> ~/mount.log

3
usbremove.sh Executable file
View File

@ -0,0 +1,3 @@
touch ~/remove.log
# sudo umount /media/usb