-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest-binary.sh
executable file
·73 lines (58 loc) · 1.77 KB
/
test-binary.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
#!/bin/bash
# Update airspy_adsb binary
set -e
verlte() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
libc=$(ldd --version | grep -i glibc | grep -o -e '[0-9.]*$')
ARCH=arm
if dpkg --print-architecture | grep -F -e armhf &>/dev/null; then
ARCH=arm
elif uname -m | grep -F -e arm64 -e aarch64 &>/dev/null; then
ARCH=arm64
elif uname -m | grep -F -e arm &>/dev/null; then
ARCH=arm
elif dpkg --print-architecture | grep -F -e i386 &>/dev/null; then
ARCH=i386
elif uname -m | grep -F -e x86_64 &>/dev/null; then
ARCH=x86_64
if cat /proc/cpuinfo | grep flags | grep popcnt | grep sse4_2 &>/dev/null; then
ARCH=nehalem
fi
else
echo "Unable to download a program version for your platform!"
fi
URL="https://github.com/wiedehopf/airspy-conf/raw/master/test"
OS="buster"
required_libc="2.28"
if [[ -z "$libc" ]] || verlt "$libc" "$required_libc"; then
OS="stretch"
echo "----------------"
echo "Seems your system is a bit old, performance may be worse than on buster or newer!"
echo "$libc <= $required_libc"
echo "----------------"
fi
binary="${URL}/${OS}/airspy_adsb-linux-${ARCH}.tgz"
function download() {
cd /tmp/
if ! wget -O airspy.tgz "$binary"; then
echo "download error?!"
exit 1
fi
rm -f ./airspy_adsb
tar xzf airspy.tgz
}
download
if ! ./airspy_adsb -h &>/dev/null; then
echo "ARCH=${ARCH} libc=${libc} Error, can't execute the binary, please report $(uname -m) and the above error."
exit 1
fi
# ------------------------------
systemctl stop airspy_adsb &>/dev/null || true
cp -f airspy_adsb /usr/local/bin/
systemctl restart airspy_adsb
echo "------------------------"
echo "airspy-conf update finished successfully!"