-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect-logs.sh
executable file
·69 lines (58 loc) · 1.89 KB
/
collect-logs.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# This file originates from Kite's Circuit Sword control board project.
# Author: Kite (Giles Burgess)
#
# THIS HEADER MUST REMAIN WITH THIS FILE AT ALL TIMES
#
# This firmware is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This firmware is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this repo. If not, see <http://www.gnu.org/licenses/>.
#
if [ "$EUID" -ne 0 ]
then echo "Please run as root (sudo)"
exit 1
fi
# Clear a bit of the screen
echo; echo; echo; echo; echo; echo
# Define some vars
LOGCOLLECTPATH="/boot/kite-logcollect"
COMPRESSEDNAME="kite-logcollect.tar.gz"
COMPRESSEDPATH="/boot/${COMPRESSEDNAME}"
# Create the log dir
mkdir -p ${LOGCOLLECTPATH}
# Clear out any existing logs
rm -f ${COMPRESSEDPATH}
rm -rf "${LOGCOLLECTPATH}/*"
# Collect files
cp /var/log/messages "${LOGCOLLECTPATH}/messages.txt"
cp /var/log/syslog "${LOGCOLLECTPATH}/syslog.txt"
# Run some commands
iwconfig > "${LOGCOLLECTPATH}/iwconfig.txt" 2>&1
rfkill list all > "${LOGCOLLECTPATH}/rfkill.txt" 2>&1
git -C /home/pi/Circuit-Shield/ rev-parse HEAD > "${LOGCOLLECTPATH}/cs-git.txt" 2>&1
lsusb > "${LOGCOLLECTPATH}/lsusb.txt" 2>&1
# Compress the logs
tar -zcf ${COMPRESSEDPATH} ${LOGCOLLECTPATH}
# Log the completion
echo "#########################"
echo "LOG COLLECTION COMPLETE"
echo
echo "INSERT INTO PC AND GRAB"
echo "THE FILE:"
echo
echo " ${COMPRESSEDNAME}"
echo
echo "SAFE TO POWER OFF"
echo "#########################"
echo "(press enter for console)"
read