better service states

pull/12/head
Tom Early 7 years ago
parent 176d0e8ee2
commit 06732d2bd0

@ -82,33 +82,47 @@ InstallSystem () {
} }
BaseStatus () { BaseStatus () {
ActiveGate=$( systemctl show -p ActiveState --value qngateway ) local LoadGate SubGate LoadLink SubLink LoadDTMF SubDTMF
LoadGate=$( systemctl show -p LoadState --value qngateway )
SubGate=$( systemctl show -p SubState --value qngateway ) SubGate=$( systemctl show -p SubState --value qngateway )
ActiveLink=$( systemctl show -p ActiveState --value qnlink ) LoadLink=$( systemctl show -p LoadState --value qnlink )
SubLink=$( systemctl show -p SubState --value qnlink ) SubLink=$( systemctl show -p SubState --value qnlink )
ActiveDTMF=$( systemctl show -p ActiveState --value qndtmf ) LoadDTMF=$( systemctl show -p LoadState --value qndtmf )
SubDTMF=$( systemctl show -p SubState --value qndtmf ) SubDTMF=$( systemctl show -p SubState --value qndtmf )
echo -n "QnetGateway " if [[ $LoadGate == 'loaded' ]]; then
if [[ "$ActiveGate" == "inactive" ]]; then if [[ $SubGate == 'running' ]]; then
echo "is not installed" GateState='running'
else
GateState='stopped'
fi
else else
echo "ActiveState is $ActiveGate SubState is $SubGate" GateState='non installed'
fi fi
echo -n "QnetLink " echo "QetGateway is $GateState"
if [[ "$ActiveLink" == "inactive" ]]; then if [[ $LoadLink == 'loaded' ]]; then
echo "is not installed" if [[ $SubLink == 'running' ]]; then
LinkState='running'
else
LinkState='stopped'
fi
else else
echo "ActiveState is $ActiveLink SubState is $SubLink" LinkState='non installed'
fi fi
echo -n "DTMF " echo "QetLink is $LinkState"
if [[ "$ActiveDTMF" == "inactive" ]]; then if [[ $LoadDTMF == 'loaded' ]]; then
echo "is not installed" if [[ $SubDTMF == 'running' ]]; then
DTMFState='running'
else
DTMFState='stopped'
fi
else else
echo "ActiveState is $ActiveDTMF SubState is $SubDTMF" DTMFState='non installed'
fi fi
echo "DTMF is $DTMFState"
} }
ModuleStatus () { ModuleStatus () {
local LoadState SubState
if [ -z ${3} ]; then if [ -z ${3} ]; then
echo "Module ${2^^} - EMPTY" echo "Module ${2^^} - EMPTY"
else else
@ -118,14 +132,18 @@ ModuleStatus () {
else else
process="${3}" process="${3}"
fi fi
ActiveState=$( systemctl show -p ActiveState --value $process ) LoadState=$( systemctl show -p LoadState --value $process )
SubState=$( systemctl show -p SubState --value $process ) SubState=$( systemctl show -p SubState --value $process )
echo -n "Module ${2^^} - ${3^^}" if [[ "$LoadState" == "loaded" ]]; then
if [[ "$ActiveState" == "inactive" ]]; then if [[ $SubState == "running" ]]; then
echo " is not installed" ModuleState[$1]='running'
else
ModuleState[$1]='stopped'
fi
else else
echo " ActiveState is $ActiveState SubState is $SubState" ModuleState[$1]='not installed'
fi fi
echo "Module ${2^^} - ${3^^} is $ModuleState[$1]"
fi fi
} }
@ -196,10 +214,14 @@ while [[ "$ans" != q* ]]; do
ModuleStatus 1 b "$module_b" ModuleStatus 1 b "$module_b"
ModuleStatus 2 c "$module_c" ModuleStatus 2 c "$module_c"
echo echo
if [[ "$ActiveGate" == "inactive" ]] || [[ "$ActiveLink" == "inactive" ]]; then if [[ "$LoadGate" == "not-found" ]] || [[ "$LoadLink" == "not-found" ]]; then
echo "i : Install configured system" echo "i : Install configured system"
else
echo "u : Uninstall configured System" echo "u : Uninstall configured System"
fi
if [[ "$LoadDTMF" == "not-found" ]]; then
echo "D : Install DTMF" echo "D : Install DTMF"
else
echo "U : Uninstall DTMF" echo "U : Uninstall DTMF"
fi fi
echo "c : Clean (remove temporary files and locally build executables)" echo "c : Clean (remove temporary files and locally build executables)"

Loading…
Cancel
Save

Powered by TurnKey Linux.