Skip to content

Commit 6c9f3fa

Browse files
author
David Ranch
committed
improved logging, running remotely, and script comments
1 parent bee64e1 commit 6c9f3fa

File tree

1 file changed

+70
-24
lines changed

1 file changed

+70
-24
lines changed

Diff for: dw-start.sh

+70-24
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Dire Wolf automatically.
55

66
# See User Guide for more discussion.
7-
# For release 1.4 it is section 5.7 "Automatic Start Up After Reboot"
7+
# For release 1.6 it is section 5.7 "Automatic Start Up After Reboot"
88
# but it could change in the future as more information is added.
99

1010

1111
# Versioning (this file, not direwolf version)
1212
#-----------
13-
# v1.5 - KI6ZHD - Update to auto-detect binary paths and updated GUI start
13+
# v1.6 - KI6ZHD - Update to auto-detect binary paths and updated GUI start
1414
# v1.3 - KI6ZHD - added variable support for direwolf binary location
1515
# v1.2 - KI6ZHD - support different versions of VNC
1616
# v1.1 - KI6ZHD - expanded version to support running on text-only displays with
@@ -32,27 +32,35 @@
3232

3333
RUNMODE=AUTO
3434

35-
# Location of the direwolf binary. Depends on $PATH as shown.
36-
# change this if you want to use some other specific location.
37-
# e.g. DIREWOLF="/usr/local/bin/direwolf"
3835

39-
DIREWOLF="direwolf"
36+
# Location of the direwolf binary. Depends on $PATH as shown and how the program
37+
# was installed. Change this if you want to use some other specific location.
38+
# e.g. DIREWOLF="/usr/bin/direwolf"
39+
40+
DIREWOLF="/usr/local/bin/direwolf"
41+
4042

4143
#Direwolf start up command :: two examples where example one is enabled
4244
#
4345
# 1. For normal operation as TNC, digipeater, IGate, etc.
4446
# Print audio statistics each 100 seconds for troubleshooting.
4547
# Change this command to however you wish to start Direwolf
46-
47-
DWCMD="$DIREWOLF -a 100"
48-
49-
#---------------------------------------------------------------
5048
#
5149
# 2. Alternative for running with SDR receiver.
5250
# Piping one application into another makes it a little more complicated.
5351
# We need to use bash for the | to be recognized.
52+
#
53+
# DWCMD="bash -c 'rtl_fm -f 144.39M - | direwolf -c sdr.conf -r 24000 -D 1 -'"
54+
#
55+
# Config:
56+
# This command assumes the direwolf.conf file is in the CURRENT directory that
57+
# the user is within per the "pwd" command. If not, enhance this command to
58+
# use the "-c" option such as "-c /home/pi/direwolf.conf" syntax
59+
#
60+
# Options:
61+
# Any other direwolf options such as turning on/off color, etc should go in here
5462

55-
#DWCMD="bash -c 'rtl_fm -f 144.39M - | direwolf -c sdr.conf -r 24000 -D 1 -'"
63+
DWCMD="$DIREWOLF -a 100 -t 0"
5664

5765

5866
#Where will logs go - needs to be writable by non-root users
@@ -66,24 +74,42 @@ LOGFILE=/var/tmp/dw-start.log
6674
#Status variables
6775
SUCCESS=0
6876

77+
function CHKERR {
78+
if [ $? -ne 0 ]; then
79+
echo -e "Last command failed"
80+
exit 1
81+
fi
82+
}
83+
6984
function CLI {
85+
#Auto-determine if screen is installed
7086
SCREEN=`which screen`
7187
if [ $? -ne 0 ]; then
7288
echo -e "Error: screen is not installed but is required for CLI mode. Aborting"
7389
exit 1
7490
fi
7591

76-
echo "Direwolf in CLI mode start up"
77-
echo "Direwolf in CLI mode start up" >> $LOGFILE
92+
echo "Direwolf in CLI mode start up. All log output recorded to $LOGFILE"
93+
echo "Direwolf in CLI mode start up. All log output recorded to $LOGFILE" >> $LOGFILE
7894

7995
# Screen commands
8096
# -d m :: starts the command in detached mode
8197
# -S :: name the session
98+
# --
99+
# Remove the "-d m" if you don't want screen to detach and not show direwolf"
82100
$SCREEN -d -m -S direwolf $DWCMD >> $LOGFILE
101+
CHKERR
83102
SUCCESS=1
103+
echo " "
104+
echo " " >> $LOGFILE
84105

85106
$SCREEN -list direwolf
107+
CHKERR
86108
$SCREEN -list direwolf >> $LOGFILE
109+
echo -e "\nYou can re-attach to the Direwolf screen with:"
110+
echo -e " screen -dr direwolf"
111+
echo -e "\nYou can re-attach to the Direwolf screen with:" >> $LOGFILE
112+
echo -e " screen -dr direwolf" >> $LOGFILE
87113

88114
echo "-----------------------"
89115
echo "-----------------------" >> $LOGFILE
@@ -98,7 +124,10 @@ function GUI {
98124
# If VNC server is running, use its display number.
99125
# Otherwise default to :0 (the Xwindows on the HDMI display)
100126
#
101-
export DISPLAY=":0"
127+
if [ ! $DISPLAY ]; then
128+
echo "No Xdisplay set"
129+
#export DISPLAY=":0"
130+
fi
102131

103132
#Reviewing for RealVNC sessions (stock in Raspbian Pixel)
104133
if [ -n "`ps -ef | grep vncserver-x11-serviced | grep -v grep`" ]; then
@@ -112,23 +141,29 @@ function GUI {
112141
export DISPLAY="$d"
113142
fi
114143

115-
echo "Direwolf in GUI mode start up"
116-
echo "Direwolf in GUI mode start up" >> $LOGFILE
144+
echo "Direwolf in GUI mode start up. All log output recorded to $LOGFILE"
145+
echo "Direwolf in GUI mode start up. All log output recorded to $LOGFILE" >> $LOGFILE
117146
echo "DISPLAY=$DISPLAY"
118147
echo "DISPLAY=$DISPLAY" >> $LOGFILE
119148

120149
#
121150
# Auto adjust the startup for your particular environment: gnome-terminal, xterm, etc.
122151
#
123152

124-
if [ -x /usr/bin/lxterminal ]; then
125-
/usr/bin/lxterminal -t "Dire Wolf" -e "$DWCMD" &
153+
if [ $(which lxterminal) ]; then
154+
#echo "DEBUG: lxterminal stanza"
155+
$(which lxterminal) -l -t "Dire Wolf" -e "$DWCMD" &
156+
CHKERR
126157
SUCCESS=1
127-
elif [ -x /usr/bin/xterm ]; then
128-
/usr/bin/xterm -bg white -fg black -e "$DWCMD" &
158+
elif [ $(which xterm) ]; then
159+
#echo "DEBUG: xterm stanza"
160+
$(which xterm) -bg white -fg black -e "$DWCMD" &
161+
CHKERR
129162
SUCCESS=1
130-
elif [ -x /usr/bin/x-terminal-emulator ]; then
131-
/usr/bin/x-terminal-emulator -e "$DWCMD" &
163+
elif [ $(which x-terminal-emulator) ]; then
164+
#echo "DEBUG: x-xterm-emulator stanza"
165+
$(which x-terminal-emulator) -e "$DWCMD" &
166+
CHKERR
132167
SUCCESS=1
133168
else
134169
echo "Did not find an X terminal emulator. Reverting to CLI mode"
@@ -147,12 +182,23 @@ function GUI {
147182
#
148183
export PATH=/usr/local/bin:$PATH
149184

150-
#Log the start of the script run and re-run
151-
date >> $LOGFILE
185+
if [ ! -x $DIREWOLF ]; then
186+
echo -e "\nError: Direwolf program not found per the DIREWOLF variable in script. Aborting.\n"
187+
echo -e "\nError: Direwolf program not found per the DIREWOLF variable in script. Aborting.\n" >> $LOGFILE
188+
exit 1
189+
fi
152190

153191
# First wait a little while in case we just rebooted
154192
# and the desktop hasn't started up yet.
155193
#
194+
echo -e "\ndw-start.sh"
195+
echo -e "-----------"
196+
#Log the start of the script run and re-run
197+
date
198+
date >> $LOGFILE
199+
200+
#echo -e "Sleeping for 30 seconds to let any boot/reboot delays conclude"
201+
echo -e "Sleeping for 30 seconds to let any boot/reboot delays conclude"
156202
sleep 30
157203

158204

0 commit comments

Comments
 (0)