forked from MihajloPi/raspberry-noaa-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
support.sh
executable file
·110 lines (96 loc) · 2.9 KB
/
support.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# Purpose: Output environmental information about the installed environment
# to aid with support requests via GitHub, Discord, etc.
#
# Example:
# ./support.sh
START_TIME=$(date '+%s')
LATEST_GIT_HASH=$(git rev-parse HEAD)
ARCH=$(uname -a)
CPUS=$(lscpu | grep "CPU(s):" | awk '{print $2}')
GIT_CHANGES=$(git diff --name-only)
SDR_INFO=$(rtl_eeprom 2>&1)
RPI_MODEL=$(cat /proc/device-tree/model | tr -d '\0')
DISK_LAYOUT=$(lsblk)
DB_TABLES=$(sqlite3 db/panel.db "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';")
echo "============================================="
echo "Details about environment"
echo "============================================="
echo "Current local date/time: $(date -d @$START_TIME)"
echo "Current date/time (ms): ${START_TIME}"
echo "Repo git hash: ${LATEST_GIT_HASH}"
echo "Raspberry Pi Model: ${RPI_MODEL}"
echo "Architecture: ${ARCH}"
echo "Num CPUs: ${CPUS}"
echo "---------------------------------------------"
echo "'at' Scheduled Jobs (Captures):"
# get the at jobs
atq_jobs=()
while IFS= read -r res; do
atq_jobs+=("${res}")
done < <(atq)
# parse and save the job information
AT_COMMANDS=()
for job in "${atq_jobs[@]}"; do
job_id=$(echo "${job}" | awk '{print $1}')
cmd=$(at -c $job_id | grep -e "receive_meteor.sh" -e "receive_noaa.sh")
AT_COMMANDS+=("[${job}] -> ${cmd}")
done
# output the job details (if any available)
if [ "${#AT_COMMANDS[@]}" == "0" ]; then
echo " (None)"
else
for cmd in "${AT_COMMANDS[@]}"; do
echo " * ${cmd}"
done
fi
echo "---------------------------------------------"
echo "Satellite SDR Settings:"
while IFS= read -r res; do
echo " $res"
done < <(grep -E 'noaa_(15|18|19)_|meteor_m2_' config/settings.yml)
echo "---------------------------------------------"
echo "USB Device Map:"
while IFS= read -r res; do
echo " $res"
done < <(lsusb)
echo "---------------------------------------------"
echo "Disk Info:"
while IFS= read -r res; do
echo " $res"
done < <(lsblk)
echo "---------------------------------------------"
echo "Disk Usage Info:"
while IFS= read -r res; do
echo " $res"
done < <(df)
echo "---------------------------------------------"
echo "Memory Info:"
while IFS= read -r res; do
echo " $res"
done < <(cat /proc/meminfo | grep Mem)
echo "---------------------------------------------"
echo "Git source files changed:"
if [ -z "${GIT_CHANGES}" ]; then
echo " (None)"
else
for file in $GIT_CHANGES; do
echo " ${file}"
done
fi
echo "---------------------------------------------"
echo "SDR Information:"
echo -e "${SDR_INFO}"
echo "---------------------------------------------"
echo "Database tables:"
if [ -z "${DB_TABLES}" ]; then
echo " (None)"
else
for db_table in $DB_TABLES; do
table_schema=$(sqlite3 db/panel.db ".schema ${db_table}")
echo " ${db_table} =>"
echo " ${table_schema}"
echo ""
done
fi