mirror of
https://github.com/AG7GN/nexus-utilities.git
synced 2025-05-31 13:50:12 -07:00
Expanded check for initial conditions and other bug fixes
This commit is contained in:
parent
a3996615da
commit
9cf3bcbaeb
@ -15,7 +15,7 @@
|
|||||||
#%
|
#%
|
||||||
#================================================================
|
#================================================================
|
||||||
#- IMPLEMENTATION
|
#- IMPLEMENTATION
|
||||||
#- version ${SCRIPT_NAME} 1.3.7
|
#- version ${SCRIPT_NAME} 1.3.9
|
||||||
#- author Steve Magnuson, AG7GN
|
#- author Steve Magnuson, AG7GN
|
||||||
#- license CC-BY-SA Creative Commons License
|
#- license CC-BY-SA Creative Commons License
|
||||||
#- script_id 0
|
#- script_id 0
|
||||||
@ -96,7 +96,7 @@ function loadSettings () {
|
|||||||
echo "$CONFIG_FILE found." >&3
|
echo "$CONFIG_FILE found." >&3
|
||||||
source "$CONFIG_FILE"
|
source "$CONFIG_FILE"
|
||||||
else # Set some default values in a new config file
|
else # Set some default values in a new config file
|
||||||
echo "Config file $CONFIG_FILE not found. Creating a new one with default values." >&3
|
echo -e "Config file $CONFIG_FILE not found.\nCreating a new one with default values." >&3
|
||||||
echo "declare -gA F" > "$CONFIG_FILE"
|
echo "declare -gA F" > "$CONFIG_FILE"
|
||||||
echo "F[_CALL_]='N0CALL'" >> "$CONFIG_FILE"
|
echo "F[_CALL_]='N0CALL'" >> "$CONFIG_FILE"
|
||||||
echo "F[_MODEM_]='1200'" >> "$CONFIG_FILE"
|
echo "F[_MODEM_]='1200'" >> "$CONFIG_FILE"
|
||||||
@ -166,15 +166,12 @@ AGWPORT ${F[_AGWPORT_]}
|
|||||||
KISSPORT ${F[_KISSPORT_]}
|
KISSPORT ${F[_KISSPORT_]}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if command -v pat >/dev/null 2>&1 && [ -s $PAT_CONFIG ]
|
|
||||||
then
|
|
||||||
PAT_START_HTTP="${F[_PAT_HTTP_]}"
|
PAT_START_HTTP="${F[_PAT_HTTP_]}"
|
||||||
PAT_CALL="$(jq -r ".mycall" $PAT_CONFIG)"
|
PAT_CALL="$(jq -r ".mycall" $PAT_CONFIG)"
|
||||||
PAT_PASSWORD="$(jq -r ".secure_login_password" $PAT_CONFIG)"
|
PAT_PASSWORD="$(jq -r ".secure_login_password" $PAT_CONFIG)"
|
||||||
PAT_HTTP_PORT="$(jq -r ".http_addr" $PAT_CONFIG | cut -d: -f2)"
|
PAT_HTTP_PORT="$(jq -r ".http_addr" $PAT_CONFIG | cut -d: -f2)"
|
||||||
PAT_TELNET_PORT="$(jq -r ".telnet.listen_addr" $PAT_CONFIG | cut -d: -f2)"
|
PAT_TELNET_PORT="$(jq -r ".telnet.listen_addr" $PAT_CONFIG | cut -d: -f2)"
|
||||||
PAT_LOCATOR="$(jq -r ".locator" $PAT_CONFIG)"
|
PAT_LOCATOR="$(jq -r ".locator" $PAT_CONFIG)"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#============================
|
#============================
|
||||||
@ -287,14 +284,36 @@ do
|
|||||||
done
|
done
|
||||||
shift $((${OPTIND} - 1)) ## shift options
|
shift $((${OPTIND} - 1)) ## shift options
|
||||||
|
|
||||||
|
# Ensure only one instance of this script is running.
|
||||||
|
pidof -o %PPID -x $(basename "$0") >/dev/null && exit 1
|
||||||
|
|
||||||
# Check for required apps.
|
# Check for required apps.
|
||||||
for A in yad pat jq sponge rigctld
|
for A in yad pat jq sponge rigctld
|
||||||
do
|
do
|
||||||
command -v $A >/dev/null 2>&1 || Die "$A is required but not installed."
|
command -v $A >/dev/null 2>&1 || Die "$A is required but not installed."
|
||||||
done
|
done
|
||||||
|
|
||||||
# Ensure only one instance of this script is running.
|
# If this is the first time running this script, don't attempt to start Direwolf
|
||||||
pidof -o %PPID -x $(basename "$0") >/dev/null && exit 1
|
# or pat until user configures both.
|
||||||
|
if [[ -s $PAT_CONFIG && -s $CONFIG_FILE ]]
|
||||||
|
then # Direwolf and pat configuration files exist
|
||||||
|
if [[ $(jq -r ".mycall" $PAT_CONFIG) == "" || ${F[_ADEVICE_CAPTURE_]} == "null" ]]
|
||||||
|
then # Config files present, but not configured
|
||||||
|
FIRST_RUN=true
|
||||||
|
else # Config files present and configured
|
||||||
|
FIRST_RUN=false
|
||||||
|
fi
|
||||||
|
else # No configuration files exist
|
||||||
|
FIRST_RUN=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for pat's config.json. Create it if necessary
|
||||||
|
if ! [[ -s $PAT_CONFIG ]]
|
||||||
|
then
|
||||||
|
cd $HOME
|
||||||
|
export EDITOR=ed
|
||||||
|
echo -n "" | pat configure >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
#============================
|
#============================
|
||||||
# MAIN SCRIPT
|
# MAIN SCRIPT
|
||||||
@ -361,6 +380,10 @@ do
|
|||||||
echo "Done." >&3
|
echo "Done." >&3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $FIRST_RUN == true ]]
|
||||||
|
then
|
||||||
|
echo -e "Configure Direwolf TNC and pat in the \"Configure TNC\" and \"Configure pat\" tabs,\nthen click \"Restart...\" button below." >&3
|
||||||
|
else # Not a first run. pat and Direwolf configured so start 'em
|
||||||
# Start Direwolf
|
# Start Direwolf
|
||||||
[[ ${F[_AUDIOSTATS_]} == 0 ]] || DIREWOLF+=" -a ${F[_AUDIOSTATS_]}"
|
[[ ${F[_AUDIOSTATS_]} == 0 ]] || DIREWOLF+=" -a ${F[_AUDIOSTATS_]}"
|
||||||
$DIREWOLF -c $DW_CONFIG >&3 2>&3 &
|
$DIREWOLF -c $DW_CONFIG >&3 2>&3 &
|
||||||
@ -391,8 +414,9 @@ do
|
|||||||
|
|
||||||
# Start pat
|
# Start pat
|
||||||
[[ $PAT_START_HTTP == TRUE ]] && $PAT >&3 2>&3 &
|
[[ $PAT_START_HTTP == TRUE ]] && $PAT >&3 2>&3 &
|
||||||
|
fi
|
||||||
|
|
||||||
# Set up second tab, for configuring Direwolf.
|
# Set up tab for configuring Direwolf.
|
||||||
yad --plug="$ID" --tabnum=2 \
|
yad --plug="$ID" --tabnum=2 \
|
||||||
--text="<b><big><big>Direwolf TNC Configuration</big></big></b>\n\n \
|
--text="<b><big><big>Direwolf TNC Configuration</big></big></b>\n\n \
|
||||||
<b><u><big>Typical Direwolf Sound Card and PTT Settings</big></u></b>\n \
|
<b><u><big>Typical Direwolf Sound Card and PTT Settings</big></u></b>\n \
|
||||||
@ -421,10 +445,7 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
--focus-field 1 > $TMPDIR/CONFIGURE_TNC.txt &
|
--focus-field 1 > $TMPDIR/CONFIGURE_TNC.txt &
|
||||||
YAD_PIDs+=( $! )
|
YAD_PIDs+=( $! )
|
||||||
|
|
||||||
# If pat is installed, set up a 3rd tab for it's configuration
|
# Set up tab for pat configuration
|
||||||
PAT_TAB=""
|
|
||||||
if command -v pat >/dev/null && [ -s $PAT_CONFIG ]
|
|
||||||
then # pat is installed, so add a configuration dialog for it.
|
|
||||||
yad --plug="$ID" --tabnum=3 \
|
yad --plug="$ID" --tabnum=3 \
|
||||||
--text="<b><big><big>pat Configuration</big></big></b>\n\n \
|
--text="<b><big><big>pat Configuration</big></big></b>\n\n \
|
||||||
Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
||||||
@ -452,13 +473,6 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
STOP_BUTTON_TEXT="TNC"
|
STOP_BUTTON_TEXT="TNC"
|
||||||
RESTART_BUTTON_TEXT="Restart Direwolf TNC"
|
RESTART_BUTTON_TEXT="Restart Direwolf TNC"
|
||||||
[[ $PAT_START_HTTP == TRUE ]] && AND_PAT=" and pat" || AND_PAT=""
|
[[ $PAT_START_HTTP == TRUE ]] && AND_PAT=" and pat" || AND_PAT=""
|
||||||
else # pat is not installed. Print a message to that effect.
|
|
||||||
yad --plug="$ID" --tabnum=3 \
|
|
||||||
--info --text-align=center \
|
|
||||||
--text="<b>pat is not installed.\nRun 'Update Pi and Ham Apps' from the Hamradio menu to install it.</b>"
|
|
||||||
--borders=20 &
|
|
||||||
YAD_PIDs+=( $! )
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up a notebook with the 3 tabs.
|
# Set up a notebook with the 3 tabs.
|
||||||
yad --title="Direwolf TNC and pat $VERSION" --text="<b><big>Direwolf TNC$AND_PAT Configuration and Operation</big></b>" \
|
yad --title="Direwolf TNC and pat $VERSION" --text="<b><big>Direwolf TNC$AND_PAT Configuration and Operation</big></b>" \
|
||||||
@ -477,7 +491,7 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
1|252) # User click Exit button or closed window.
|
1|252) # User click Exit button or closed window.
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
0) # Read and handle the Configure Direwolf TNC tab yad output
|
0) # Read and handle the Configure TNC tab yad output
|
||||||
[[ -s $TMPDIR/CONFIGURE_TNC.txt ]] || Die "Unexpected input from dialog"
|
[[ -s $TMPDIR/CONFIGURE_TNC.txt ]] || Die "Unexpected input from dialog"
|
||||||
IFS='|' read -r -a TF < "$TMPDIR/CONFIGURE_TNC.txt"
|
IFS='|' read -r -a TF < "$TMPDIR/CONFIGURE_TNC.txt"
|
||||||
F[_CALL_]="${TF[0]^^}"
|
F[_CALL_]="${TF[0]^^}"
|
||||||
@ -489,8 +503,8 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
F[_AUDIOSTATS_]="${TF[6]}"
|
F[_AUDIOSTATS_]="${TF[6]}"
|
||||||
F[_AGWPORT_]="${TF[7]}"
|
F[_AGWPORT_]="${TF[7]}"
|
||||||
F[_KISSPORT_]="${TF[8]}"
|
F[_KISSPORT_]="${TF[8]}"
|
||||||
if command -v pat >/dev/null && [ -s $PAT_CONFIG ]
|
|
||||||
then # Read and handle the Configure pat tab yad output
|
# Read and handle the Configure pat tab yad output
|
||||||
[[ -s $TMPDIR/CONFIGURE_PAT.txt ]] || Die "Unexpected input from dialog"
|
[[ -s $TMPDIR/CONFIGURE_PAT.txt ]] || Die "Unexpected input from dialog"
|
||||||
IFS='|' read -r -a TF < "$TMPDIR/CONFIGURE_PAT.txt"
|
IFS='|' read -r -a TF < "$TMPDIR/CONFIGURE_PAT.txt"
|
||||||
PAT_CALL="${TF[0]^^}"
|
PAT_CALL="${TF[0]^^}"
|
||||||
@ -503,6 +517,7 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
F[_TXTAIL_]="${TF[7]}"
|
F[_TXTAIL_]="${TF[7]}"
|
||||||
F[_PERSIST_]="${TF[8]}"
|
F[_PERSIST_]="${TF[8]}"
|
||||||
F[_SLOTTIME_]="${TF[9]}"
|
F[_SLOTTIME_]="${TF[9]}"
|
||||||
|
|
||||||
# Update the pat config.json file with the new data.
|
# Update the pat config.json file with the new data.
|
||||||
cat $PAT_CONFIG | jq \
|
cat $PAT_CONFIG | jq \
|
||||||
--arg C "$PAT_CALL" \
|
--arg C "$PAT_CALL" \
|
||||||
@ -511,13 +526,19 @@ Click the <b>Restart...</b> button below after you make your changes.\n\n" \
|
|||||||
--arg T "0.0.0.0:$PAT_TELNET_PORT" \
|
--arg T "0.0.0.0:$PAT_TELNET_PORT" \
|
||||||
--arg L "$PAT_LOCATOR" \
|
--arg L "$PAT_LOCATOR" \
|
||||||
'.mycall = $C | .secure_login_password = $P | .http_addr = $H | .telnet.listen_addr = $T | .locator = $L' | sponge $PAT_CONFIG
|
'.mycall = $C | .secure_login_password = $P | .http_addr = $H | .telnet.listen_addr = $T | .locator = $L' | sponge $PAT_CONFIG
|
||||||
fi
|
|
||||||
# Update the yad configuration file.
|
# Update the yad configuration file.
|
||||||
echo "declare -gA F" > "$CONFIG_FILE"
|
echo "declare -gA F" > "$CONFIG_FILE"
|
||||||
for J in "${!F[@]}"
|
for J in "${!F[@]}"
|
||||||
do
|
do
|
||||||
echo "F[$J]='${F[$J]}'" >> "$CONFIG_FILE"
|
echo "F[$J]='${F[$J]}'" >> "$CONFIG_FILE"
|
||||||
done
|
done
|
||||||
|
if [[ $(jq -r ".mycall" $PAT_CONFIG) == "" || ${F[_ADEVICE_CAPTURE_]} == "null" ]]
|
||||||
|
then
|
||||||
|
FIRST_RUN=true
|
||||||
|
else
|
||||||
|
FIRST_RUN=false
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -1 +1 @@
|
|||||||
VERSION="2.1.25"
|
VERSION="2.1.26"
|
Loading…
x
Reference in New Issue
Block a user