diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d41604d..980957d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR)) install(TARGETS dvmmon DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR)) install(FILES configs/config.example.yml configs/fne-config.example.yml configs/monitor-config.example.yml configs/iden_table.dat configs/RSSI.dat configs/rid_acl.example.dat configs/talkgroup_rules.example.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/etc) -install(PROGRAMS tools/start-dvm.sh tools/stop-dvm.sh tools/dvm-watchdog.sh tools/stop-watchdog.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +install(PROGRAMS tools/start-dvm.sh tools/stop-dvm.sh tools/dvm-watchdog.sh tools/stop-watchdog.sh tools/fne-watchdog.sh tools/start-dvm-fne.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(CODE "execute_process(COMMAND bash \"-c\" \"sed -i 's/filePath: ./filePath: \\\\/var\\\\/log\\\\//' /usr/local/etc/config.example.yml\")") install(CODE "execute_process(COMMAND bash \"-c\" \"sed -i 's/activityFilePath: ./activityFilePath: \\\\/var\\\\/log\\\\//' /usr/local/etc/config.example.yml\")") install(CODE "execute_process(COMMAND bash \"-c\" \"sed -i 's/file: iden_table.dat/file: \\\\/usr\\\\/local\\\\/etc\\\\/iden_table.dat/' /usr/local/etc/config.example.yml\")") @@ -380,6 +380,8 @@ add_custom_target(old_install COMMAND install -m 755 ../tools/stop-dvm.sh ${CMAKE_LEGACY_INSTALL_PREFIX} COMMAND install -m 755 ../tools/dvm-watchdog.sh ${CMAKE_LEGACY_INSTALL_PREFIX} COMMAND install -m 755 ../tools/stop-watchdog.sh ${CMAKE_LEGACY_INSTALL_PREFIX} + COMMAND install -m 755 ../tools/fne-watchdog.sh ${CMAKE_LEGACY_INSTALL_PREFIX} + COMMAND install -m 755 ../tools/start-dvm-fne.sh ${CMAKE_LEGACY_INSTALL_PREFIX} COMMAND mkdir -p ${CMAKE_LEGACY_INSTALL_PREFIX}/fw COMMAND if [ -e dvm-firmware_f4.elf ]\; then install -m 644 dvm-firmware_f4.elf ${CMAKE_LEGACY_INSTALL_PREFIX}/fw/dvm-firmware_f4.elf\; fi COMMAND if [ -e dvm-firmware_f4.bin ]\; then install -m 644 dvm-firmware_f4.bin ${CMAKE_LEGACY_INSTALL_PREFIX}/fw/dvm-firmware_f4.bin\; fi diff --git a/tools/fne-watchdog.sh b/tools/fne-watchdog.sh new file mode 100755 index 00000000..e0c3acaa --- /dev/null +++ b/tools/fne-watchdog.sh @@ -0,0 +1,53 @@ +#!/bin/bash +#/** +#* Digital Voice Modem - Host Software +#* GPLv2 Open Source. Use is subject to license terms. +#* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +#* +#* @package DVM / Host Software +#* +#*/ +#/* +#* Copyright (C) 2022 by Bryan Biedenkapp N2PLL +#* +#* This program is free software; you can redistribute it and/or modify +#* it under the terms of the GNU General Public License as published by +#* the Free Software Foundation; either version 2 of the License, or +#* (at your option) any later version. +#* +#* This program is distributed in the hope that it will be useful, +#* but WITHOUT ANY WARRANTY; without even the implied warranty of +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#* GNU General Public License for more details. +#* +#* You should have received a copy of the GNU General Public License +#* along with this program; if not, write to the Free Software +#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#*/ +R_PATH=/opt/dvm +pushd ${R_PATH} >/dev/null + +if [ -z $1 ]; then exit 1; fi +if [ -z $2 ]; then exit 1; fi + +PID_FILE=$1 +if [ ! -e $PID_FILE ]; then exit 98; fi +CONFIG=$2 +if [ ! -f ${R_PATH}/${CONFIG} ]; then exit 3; fi + +PID=`cat $PID_FILE` +while [ true ]; do + PS_OUT=`ps --no-headers ${PID}` + if [ ${#PS_OUT} -eq 0 ]; then + logger "dvmfne PID ${PID} not running -- restarting ${PID_FILE} ${CONFIG}" + ${R_PATH}/start-dvm-fne.sh ${CONFIG} ${PID_FILE} >/dev/null + ERRNO=$? + if [ $ERRNO -ne 0 ]; then + logger "dvmfne start-dvm.sh script failed to start; errno ${ERRNO}" + fi + PID=`cat $PID_FILE` + fi + sleep 5s +done + +popd >/dev/null diff --git a/tools/start-dvm-fne.sh b/tools/start-dvm-fne.sh new file mode 100755 index 00000000..d1076d19 --- /dev/null +++ b/tools/start-dvm-fne.sh @@ -0,0 +1,55 @@ +#!/bin/bash +#/** +#* Digital Voice Modem - Host Software +#* GPLv2 Open Source. Use is subject to license terms. +#* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +#* +#* @package DVM / Host Software +#* +#*/ +#/* +#* Copyright (C) 2022 by Bryan Biedenkapp N2PLL +#* +#* This program is free software; you can redistribute it and/or modify +#* it under the terms of the GNU General Public License as published by +#* the Free Software Foundation; either version 2 of the License, or +#* (at your option) any later version. +#* +#* This program is distributed in the hope that it will be useful, +#* but WITHOUT ANY WARRANTY; without even the implied warranty of +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#* GNU General Public License for more details. +#* +#* You should have received a copy of the GNU General Public License +#* along with this program; if not, write to the Free Software +#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#*/ +R_PATH=/opt/dvm +pushd ${R_PATH} >/dev/null + +if [ "`pwd`" != "${R_PATH}" ]; then exit 99; fi +if [ -z $1 ]; then exit 2; fi + +CONFIG=$1 +if [ ! -f ${R_PATH}/${CONFIG} ]; then exit 3; fi +PID_FILE=$2 +if [ -z $2 ]; then + STRIPPED_CONFIG=`basename ${CONFIG}` + STRIPPED_CONFIG=${STRIPPED_CONFIG%.yml} + PID_FILE=/tmp/dvmfne.${STRIPPED_CONFIG}.pid +fi + +COMMAND="${R_PATH}/bin/dvmfne -c ${R_PATH}/${CONFIG}" +nice -n -20 ${COMMAND} + +if [ -e /tmp/${CONFIG}.pid ]; then rm -f /tmp/${CONFIG}.pid; fi + +PID=`pgrep -f "${R_PATH}/${CONFIG}"` + +echo "${PID}" > $PID_FILE +pgrep -f "[f]ne-watchdog.*${PID_FILE}" >/dev/null +if [ $? -ne 0 ]; then + ${R_PATH}/fne-watchdog.sh $PID_FILE $CONFIG & +fi + +popd >/dev/null