17
17
18
18
# Versioning (this file, not direwolf version)
19
19
# -----------
20
+ # v1.4 - OK1BIL - added support for multiple instances, tweaked screen execution
20
21
# v1.3 - KI6ZHD - added variable support for direwolf binary location
21
22
# v1.2 - KI6ZHD - support different versions of VNC
22
23
# v1.1 - KI6ZHD - expanded version to support running on text-only displays with
23
24
# auto support; log placement change
24
25
# v1.0 - WB2OSZ - original version for Xwindow displays only
25
26
26
27
28
+ # -------------------------------------
29
+ # Configuration
30
+ # -------------------------------------
27
31
28
32
# How are you running Direwolf : within a GUI (Xwindows / VNC) or CLI mode
29
33
#
36
40
# CLI mode is suited for say a Raspberry Pi running the Jessie LITE version
37
41
# where it will run from the CLI w/o requiring Xwindows - uses screen
38
42
39
- RUNMODE=AUTO
43
+ RUNMODE=" AUTO"
40
44
41
45
# Location of the direwolf binary. Depends on $PATH as shown.
42
46
# change this if you want to use some other specific location.
43
47
# e.g. DIREWOLF="/usr/local/bin/direwolf"
44
48
45
49
DIREWOLF=" direwolf"
46
50
51
+ # In case direwolf is run in CLI, it is running in a screen session in the background.
52
+ # Each screen session has a name. If you want to run multiple instances of direwolf
53
+ # in parallel (i.e. two SDRs over STDIN), you need to specify unique names for the sessions.
54
+ # Note: screen is a linux tool to run user-interactive software in background.
55
+
56
+
57
+ INSTANCE=" direwolf"
58
+
59
+
60
+ # Parameters for the direwolf binary can be set here. This replaces the DWCMD variable.
61
+ # Uncomment onlye on of the variables.
47
62
48
- # Direwolf start up command :: Uncomment only one of the examples.
49
- #
50
63
# 1. For normal operation as TNC, digipeater, IGate, etc.
51
64
# Print audio statistics each 100 seconds for troubleshooting.
52
65
# Change this command to however you wish to start Direwolf
53
66
54
- DWCMD= " $DIREWOLF -a 100"
67
+ DWPARAMS= " -a 100"
55
68
56
69
# 2. FX.25 Forward Error Correction (FEC) will allow your signal to
57
70
# go farther under poor radio conditions. Add "-X 1" to the command line.
58
71
59
- # DWCMD="$DIREWOLF -a 100 -X 1"
72
+ # DWPARAMS=" -a 100 -X 1"
60
73
61
- # ---------------------------------------------------------------
62
- #
63
- # 3. Alternative for running with SDR receiver.
64
- # Piping one application into another makes it a little more complicated.
65
- # We need to use bash for the | to be recognized.
74
+ # 3. Alternative for running with SDR receiver. In case of using this, please pay attention
75
+ # to variable DWSTDIN below.
76
+
77
+ # DWPARAMS="-c /etc/direwolf/ok1abc-sdr.conf -t 0 -r 24000 -D 1 -"
66
78
67
- # DWCMD="bash -c 'rtl_fm -f 144.39M - | direwolf -c sdr.conf -r 24000 -D 1 -'"
79
+ # A command to be fed into the STDIN of the direwolf binary. Main use for this is to configure rtl-sdr input.
80
+ # Leave commented if using soundcard inputs. If using rtl-sdr, uncomment folllowing lines and set parameters as needed.
68
81
82
+ # QRG="144.8M"
83
+ # GAIN="43"
84
+ # PPM="1"
85
+ # DWSTDIN="rtl_fm -f $QRG -g $GAIN -p $PPM -"
69
86
70
- # Where will logs go - needs to be writable by non-root users
71
- LOGFILE=/var/tmp/dw-start.log
72
87
88
+ # Where will logs go - needs to be writable by non-root users
89
+ LOGFILE=" /var/tmp/dw-start.log"
90
+
91
+ # Startup delay in seconds - how long should the script wait before executing (default 30)
92
+ STARTUP_DELAY=30
93
+
94
+ # -------------------------------------
95
+ # Internal use functions
96
+ # -------------------------------------
97
+
98
+ # This function is to be recursively called from outside of this script. Its purpose
99
+ # is to avoid passing commands to screen or bash as strings, which is tricky.
100
+
101
+ function RUN_CLI () {
102
+
103
+ PARAMS=$1
104
+ STDIN=$2
105
+
106
+ if [ -z " $2 " ]; then
107
+ $DIREWOLF $PARAMS
108
+ else
109
+ $STDIN | $DIREWOLF $PARAMS
110
+ fi
111
+ exit 0
112
+
113
+ }
73
114
74
115
# -------------------------------------
75
116
# Main functions of the script
@@ -91,11 +132,15 @@ function CLI {
91
132
# Screen commands
92
133
# -d m :: starts the command in detached mode
93
134
# -S :: name the session
94
- $SCREEN -d -m -S direwolf $DWCMD >> $LOGFILE
135
+ #
136
+ # Screen is instructed to run this script again with a parameter (to execute direwolf with
137
+ # necessary parameters). This way commands do not need to be passed as string. Additionally,
138
+ # this allows for some pre-flight checks withing the screen session, should they be needed.
139
+ $SCREEN -d -m -S $INSTANCE $0 -runcli >> $LOGFILE
95
140
SUCCESS=1
96
141
97
- $SCREEN -list direwolf
98
- $SCREEN -list direwolf >> $LOGFILE
142
+ $SCREEN -list $INSTANCE
143
+ $SCREEN -list $INSTANCE >> $LOGFILE
99
144
100
145
echo " -----------------------"
101
146
echo " -----------------------" >> $LOGFILE
@@ -165,21 +210,27 @@ date >> $LOGFILE
165
210
# First wait a little while in case we just rebooted
166
211
# and the desktop hasn't started up yet.
167
212
#
168
- sleep 30
213
+ sleep $STARTUP_DELAY
169
214
170
215
171
216
#
172
217
# Nothing to do if Direwolf is already running.
173
218
#
174
219
175
- a=` ps ax | grep direwolf | grep -vi -e bash -e screen -e grep | awk ' {print $1}' `
220
+ a=` ps ax | grep $INSTANCE | grep -vi -e bash -e screen -e grep | awk ' {print $1}' `
176
221
if [ -n " $a " ]
177
222
then
178
223
# date >> /tmp/dw-start.log
179
224
# echo "Direwolf already running." >> $LOGFILE
180
225
exit
181
226
fi
182
227
228
+ # Check for parameter to recursively run this script and execute direwolf in cli
229
+ if [ $# -eq 1 ] && [ $1 == " -runcli" ]; then
230
+ RUN_CLI " $DWPARAMS " " $DWSTDIN "
231
+ exit 0
232
+ fi
233
+
183
234
# Main execution of the script
184
235
185
236
if [ $RUNMODE == " AUTO" ]; then
0 commit comments