forked from Nachtzuster/BirdNET-Pi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdump_logs.sh
More file actions
executable file
·51 lines (42 loc) · 1.65 KB
/
dump_logs.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.65 KB
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
#!/usr/bin/env bash
# A comprehensive log dumper
# set -x # Uncomment to debug
source /etc/birdnet/birdnet.conf &> /dev/null
LOG_DIR="${HOME}/BirdNET-Pi/logs"
my_dir=$HOME/BirdNET-Pi/scripts
services=$(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort)
# Create logs directory
[ -d ${LOG_DIR} ] || mkdir ${LOG_DIR}
# Create services logs
for i in "${services[@]}";do
if [ -L "/etc/systemd/system/multi-user.target.wants/${i}" ];then
journalctl -u ${i} -n 100 --no-pager > ${LOG_DIR}/${i}.log
cp -L /etc/systemd/system/multi-user.target.wants/${i} ${LOG_DIR}/${i}
fi
done
# Create password-removed birdnet.conf
sed -e '/PWD=/d' ${HOME}/BirdNET-Pi/birdnet.conf > ${LOG_DIR}/birdnet.conf
# Create password-removed Caddyfile
if [ -f /etc/caddy/Caddyfile ];then
sed -e '/basicauth/,+2d' /etc/caddy/Caddyfile > ${LOG_DIR}/Caddyfile
fi
# Get sound card specs
SOUND_CARD="$(aplay -L \
| awk -F, '/^hw:/ {print $1}' \
| grep -ve 'vc4' -e 'Head' -e 'PCH' \
| uniq)"
echo "SOUND_CARD=${SOUND_CARD}" > ${LOG_DIR}/soundcard
script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a ${LOG_DIR}/soundcard &> /dev/null
# Get system info
CALLS=("df -h" "free -h" "ifconfig" "find ${RECS_DIR}")
for i in "${CALLS[@]}";do
${i} >> ${LOG_DIR}/sysinfo
echo "
===============================================================================
===============================================================================
" >> ${LOG_DIR}/sysinfo
done
# TAR the logs into a ball
tar --remove-files -cvpzf ${HOME}/BirdNET-Pi/logs.tar.gz ${LOG_DIR} &> /dev/null
# Finished
echo "Your compressed logs are located at ${HOME}/BirdNET-Pi/logs.tar.gz"