-
Notifications
You must be signed in to change notification settings - Fork 5
/
direwolf.sh
31 lines (28 loc) · 981 Bytes
/
direwolf.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
#!/bin/bash
if [[ ! "${DIREWOLF_ENABLE^^}" =~ (TRUE|YES|1) ]]; then exit; fi
# exit if pipeline fails or unset variables
set -eu
# default values
: "${DIREWOLF_FREQ:=144800000}"
: "${DIREWOLF_CONF:=/etc/direwolf.conf}"
: "${SATNOGS_PPM_ERROR:=0}"
: "${SATNOGS_RF_GAIN:=0}"
: "${SATNOGS_APP_PATH:=/tmp/.satnogs}"
: "${SDR_BIN:=rx_fm}"
: "${DIREWOLF_BIN:=direwolf}"
: "${DIREWOLF_SAMPLERATE:=48000}"
DIREWOLF_PID="$SATNOGS_APP_PATH/direwolf.pid"
if [ "${1^^}" == "START" ]; then
echo "Starting direwolf"
$SDR_BIN -d "$SATNOGS_SOAPY_RX_DEVICE" -a "$SATNOGS_ANTENNA" -p "$SATNOGS_PPM_ERROR" -g "$SATNOGS_RF_GAIN" -f "$DIREWOLF_FREQ" -s "$DIREWOLF_SAMPLERATE" - \
| $DIREWOLF_BIN -c "$DIREWOLF_CONF" -r "$DIREWOLF_SAMPLERATE" -D 1 -t 0 &
echo $! > "$DIREWOLF_PID"
fi
if [ "${1^^}" == "STOP" ]; then
if [ -f "$DIREWOLF_PID" ]; then
echo "Stopping direwolf"
kill "$(cat "$DIREWOLF_PID")"
killall "$SDR_BIN"
rm -f "$DIREWOLF_PID"
fi
fi