aboutsummaryrefslogtreecommitdiff
path: root/install.sh
blob: a8d03f2130c8b057c271db3cb9e286a4f7916d16 (plain) (blame)
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
#! /bin/sh

set -e

# trunk-recorder install script for debian based systems
# including ubuntu 18.04/20.04 and raspbian

if [ ! -d trunk-recorder/recorders ]; then
    echo ====== ERROR: trunk-recorder top level directories not found.
    echo ====== You must change to the trunk-recorder top level directory
    echo ====== before running this script.
    exit
fi

pre_reqs() {
    PKG_LIST="gnuradio gnuradio-dev gr-osmosdr libhackrf-dev libuhd-dev libgmp-dev"
    PKG_LIST="$PKG_LIST fdkaac sox"
    PKG_LIST="$PKG_LIST git cmake build-essential libboost-all-dev libusb-1.0-0.dev libssl-dev libcurl4-openssl-dev liborc-0.4-dev"

    ISSUE=$(cat /etc/issue)
    case "$ISSUE" in
	"") echo "Well that's weird. You don't have an /etc/issue" ;;
	"Ubuntu 20.04*") PKG_LIST="$PKG_LIST pkg-config libpthread-stubs0-dev" ;;
    esac

    sudo apt-get update
    sudo apt-get install $PKG_LIST
}

freshen_repo() {
    git pull
    if [ -d build ]; then
	rm -rf build
    fi
}

do_build() {
    mkdir build
    cd build
    cmake ../
    make
    cd ..
}

do_install() {
    cd build
    sudo make install
    cd ..
}

blacklist() {
    if [ ! -f /etc/modprobe.d/blacklist-rtl.conf ]; then
	echo ====== Installing blacklist-rtl.conf for selecting the correct RTL-SDR drivers
	echo ====== Please reboot before running trunk-recorder.
	sudo install -m 0644 ./blacklist-rtl.conf /etc/modprobe.d/
    fi
}

rebuild_steps() {
    freshen_repo
    do_build
    do_install
}

install_steps() {
    pre_reqs
    rebuild_steps
    blacklist
}

case "$0" in
    *rebuild*) rebuild_steps ;;
    *) install_steps ;;
esac