From e2a2ca8c699b4d2b340d04761a6c49de9b6625b4 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Mon, 21 Jan 2019 15:42:24 -0700 Subject: [PATCH] handling MMDVMHost (un)install separately --- Makefile | 12 ++++++++---- qnadmin | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a28d1d3..c431fdc 100644 --- a/Makefile +++ b/Makefile @@ -101,18 +101,20 @@ installbase : $(BASE_PROGRAMS) gwys.txt qn.cfg systemctl daemon-reload systemctl start qnlink.service -installrelay : qnrelay $(MMPATH)/MMDVMHost $(MMPATH)/MMDVM$(MODULE).qn +installrelay : qnrelay ######### QnetRelay ######### /bin/ln -f qnrelay $(BINDIR)/qnrelay$(MODULE) sed -e "s/XXX/qnrelay$(MODULE)/" system/qnrelay.service > $(SYSDIR)/qnrelay$(MODULE) systemctl enable qnrelay$(MODULE).service systemctl daemon-reload systemctl start qnrelay$(MODULE).service + +installmmdvm : $(MMPATH)/MMDVMHost $(MMPATH)/MMDVM$(MODULE).qn ######### MMDVMHost ######### /bin/ln -f $(MMPATH)/MMDVMHost $(BINDIR)/MMDVMHost$(MODULE) /bin/ln -s $(shell pwd)/$(MMPATH)/MMDVM$(MODULE).qn $(CFGDIR) sed -e "s/XXX/MMDVMHost$(MODULE)" -e "s/YYY/MMDVM$(MODULE).qn" system/mmdvm.service > $(SYSDIR)/mmdvm$(MODULE).service - /bin/cp -f system/mmdvm.timer $(SYSDIR)/mmdvm$(MODULE) + /bin/cp -f system/mmdvm.timer $(SYSDIR)/mmdvm$(MODULE).timer systemctl enable mmdvm$(MODULE).timer systemctl daemon-reload systemctl start mmdvm$(MODULE).service @@ -175,9 +177,11 @@ uninstallrelay : /bin/rm -f $(SYSDIR)/qnrelay$(MODULE).service /bin/rm -f $(BINDIR)/qnrelay$(MODULE) systemctl daemon-reload + +uninstallmmdvm : ######### MMDVMHost ########## - systemctl stop mmdvm.service - systemctl disable mmdvm.timer + systemctl stop mmdvm$(MODULE).service + systemctl disable mmdvm$(MODULE).timer /bin/rm -f $(SYSDIR)/mmdvm$(MODULE).service /bin/rm -f $(SYSDIR)/mmdvm$(MODULE).timer /bin/rm -f $(BINDIR)/MMDVMHost$(MODULE) diff --git a/qnadmin b/qnadmin index 80a74ed..4aa104c 100755 --- a/qnadmin +++ b/qnadmin @@ -21,6 +21,21 @@ ControlC () { echo "caught SIGINT" } +InstallMMDVMHosts () { + if [ $nmmdvm -gt 0 ] && [ -e ${MMPATH}/MMDVMHost ]; then + if [ $nmmdvm -eq 1 ]; then + sudo make ${1}installmmdvm + else + sudo make MODULE=$ammdvm[0] ${1}installmmdvm + sudo make MODULE=$ammdvm[1] ${1}installmmdvm + if [ $nmmdvm -eq 3 ]; then + sudo make MODULE=$advap[2] ${1}installmmdvm + fi + fi + fi + +} + InstallSystem () { local n if [ -z ${1} ]; then @@ -138,7 +153,7 @@ ModuleStatus () { if [[ "${ModuleProcess[$1]}" == 'qnmmdvm' ]]; then ModuleProcess[$1]='qnrelay' MMDVMProcess[$1]='mmdvm' - MMDVMState[$1]='not empty' + MMDVMState[$1]='not installed' else MMDVMState[$1]='EMPTY' MMDVMProcess[$1]='' @@ -173,7 +188,11 @@ ModuleStatus () { MMDVMState[$1]='not installed' fi fi - echo "Module ${2^^} - ${3^^} is ${ModuleState[$1]}" + if [[ "$3" == 'mmdvm' ]]; then + echo "Module ${2^^} - ${ModuleProcess[$1]} is ${ModuleState[$1]} - ${MMDVMProcess[$1]} is ${MMDVMState[$1]}" + else + echo "Module ${2^^} - ${ModuleProcess[$1]} is ${ModuleState[$1]}" + fi fi } @@ -483,7 +502,7 @@ else echo "ERROR: There is no Makefile or makefile" exit 1 fi -source <( grep "^BINDIR=" $MAKEFILE ) +source <( grep -e '^BINDIR=' -e '^MMPATH=' $MAKEFILE ) if [ -z $BINDIR ]; then echo "ERROR: The BINDIR definition in $MAKEFILE is empty!" exit 1 @@ -539,6 +558,15 @@ while [[ "$ans" != q* ]]; do else echo "us : Uninstall configured System" fi + if [ -e "${MMPATH}/MMDVMHost" ] && [ $nmmdvm -gt 0 ]; then + if [[ "${MMDVMState[0]}" != 'EMPTY' ]] || [[ "${MMDVMState[1]}" != 'EMPTY' ]] || [[ "${MMDVMState[2]}" != 'EMPTY' ]]; then + if [[ "${MMDVMState[0]}" == 'not installed' ]] || [[ "${MMDVMState[1]}" != 'not installed' ]] || [[ "${MMDVMState[2]}" != 'not installed' ]]; then + echo "im : Install MMDVMHost(s)" + else + echo "um : Uninstall MMDVMHost(s)" + fi + fi + fi echo "gw : Gateway File Menu" echo if [[ "$DTMFState" == 'not installed' ]]; then @@ -568,6 +596,10 @@ while [[ "$ans" != q* ]]; do sleep 5 elif [[ "$GateState" != 'not installed' ]] && [[ "$ans" == us* ]]; then InstallSystem un + elif { [[ "${MMDVMState[0]}" == 'not installed' ]] || [[ "${MMDVMState[1]}" == 'not installed' ]] || [[ "${MMDVMState[2]}" == 'not installed' ]]; } && [ -e ${MMPATH}/MMDVMHost ] && [[ "$ans" == im* ]]; then + InstallMMDVMHosts + elif { [[ "${MMDVMState[0]}" == 'stopped' ]] || [[ "${MMDVMState[0]}" == 'running' ]] || [[ "${MMDVMState[1]}" == 'stopped' ]] || [[ "${MMDVMState[1]}" == 'running' ]] || [[ "${MMDVMState[2]}" == 'stopped' ]] || [[ "${MMDVMState[2]}" == 'running' ]]; } && [ -e ${MMPATH}/MMDVMHost ] && [[ "$ans" == um* ]]; then + InstallMMDVMHosts un elif [[ "$GateState" == 'not installed' ]] && [[ "$ans" == gp* ]]; then git pull read -p 'Press to continue: ' ans