-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnbp_only.sh
More file actions
executable file
·48 lines (33 loc) · 884 Bytes
/
Copy pathnbp_only.sh
File metadata and controls
executable file
·48 lines (33 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
export configfile=$1
. ${configfile}
. ${pythonenv}/bin/activate
cd ${scriptpath}
which python3
python3 ${scriptpath}/gpio_check.py
if [ $? -eq 1 ]; then
echo "GPIO not set - exiting script and not shutting down."
exit 1
fi
mkdir -p ${logdir}
export timestamp=`date +%Y%m%d%H%M%S`
echo "LogID: ${timestamp} CANBUS: ${canbus}"
python3 ${scriptpath}/canlanlog.py | gzip -c > ${logdir}/gmlan_${timestamp}.json.gz
echo "Detected system powerdown or canbus activity timeout. Powering off."
date
pkill python
pkill candump
sleep 1
if mount | grep /media/usb0 > /dev/null; then
echo "Mount detected. Syncing logs"
sudo mkdir /media/usb0/logs
sudo rsync -r /home/pi/logs/ /media/usb0/logs
echo "Log sync complete"
else
echo "No usb detected. Exiting to poweroff"
fi
# Wait for all IO.
sync; sleep 1
sync; sleep 1
sync; sleep 1
sudo poweroff