diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2020-06-08 17:26:06 -0400 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2020-06-08 17:26:06 -0400 |
commit | 1b3280e5ec9b66cde5e28e44d0eed41f7f1cb56d (patch) | |
tree | c0da61b0ec88fa45e75bbc34d320fe25ca3e5657 /src/appMain | |
parent | e729a543b11478657802b072059f9a7ebb33af6e (diff) | |
download | sdl_core-1b3280e5ec9b66cde5e28e44d0eed41f7f1cb56d.tar.gz |
Address comments
Diffstat (limited to 'src/appMain')
-rw-r--r-- | src/appMain/core.sh | 35 | ||||
-rw-r--r-- | src/appMain/core_external_proprietary.sh | 51 |
2 files changed, 43 insertions, 43 deletions
diff --git a/src/appMain/core.sh b/src/appMain/core.sh index a8e7d8c82c..423ef206f2 100644 --- a/src/appMain/core.sh +++ b/src/appMain/core.sh @@ -1,26 +1,21 @@ #!/bin/bash cd $(dirname $0) DIR=$(pwd) -PID_DIR=~/.sdl -if [ ! -d "$PID_DIR" ]; then - mkdir $PID_DIR -fi - -CORE_PID_FILE=${PID_DIR}/core.pid -CORE_PROCESS_NAME=SDLCore +CORE_PID_FILE=${DIR}/core.pid +CORE_APPLICATION_NAME=smartDeviceLinkCore function core_start() { if [ -f "$CORE_PID_FILE" ] && [ -n "$(ps -p $(cat $CORE_PID_FILE) -o pid=)" ]; then echo "Core is already running" return 1 - elif [ -n "$(pgrep $CORE_PROCESS_NAME)" ]; then + elif [ -n "$(pgrep -f $CORE_APPLICATION_NAME)" ]; then echo "Core is already running outside of this script" - echo "This lingering instance can be stopped using the \"kill\" command" + echo "All instances of Core can be stopped using the \"kill\" command" return 2 else - echo "Starting SmartDeviceLinkCore" - LD_LIBRARY_PATH=$DIR ${DIR}/smartDeviceLinkCore & + echo "Starting SmartDeviceLink Core" + LD_LIBRARY_PATH=$DIR ${DIR}/${CORE_APPLICATION_NAME} & CORE_PID=$! echo $CORE_PID > $CORE_PID_FILE return 0 @@ -30,7 +25,7 @@ function core_start() { function core_stop() { RESULT=1 if [ -f "$CORE_PID_FILE" ] && [ -n "$(ps -p $(cat $CORE_PID_FILE) -o pid=)" ]; then - echo "Stopping SmartDeviceLinkCore" + echo "Stopping SmartDeviceLink Core" CORE_PID=$(cat $CORE_PID_FILE) kill $CORE_PID @@ -49,25 +44,25 @@ function core_stop() { return $RESULT } -if [ x$1 == xstop ]; then +if [ "$1" == "stop" ]; then core_stop - if [ ! "$?" -eq 0 ]; then + if [ "$?" -ne 0 ]; then echo "Core is not running (or was started outside of this script)" fi -elif [ x$1 == xrestart ]; then +elif [ "$1" == "restart" ]; then core_stop if [ "$?" -eq 0 ]; then core_start else echo "Core is not running (or was started outside of this script)" fi -elif [ x$1 == xstart ]; then +elif [ "$1" == "start" ]; then core_start -elif [ x$1 == xkill ]; then +elif [ "$1" == "kill" ]; then core_stop - if [ -n "$(pgrep $CORE_PROCESS_NAME)" ]; then - echo "Killing all lingering instances of SDL Core" - killall -9 $CORE_PROCESS_NAME + pkill -9 -f $CORE_APPLICATION_NAME + if [ "$?" -eq 0 ]; then + echo "Killed all lingering instances of SDL Core" fi else echo "usage: core.sh [start/restart/stop/kill]" diff --git a/src/appMain/core_external_proprietary.sh b/src/appMain/core_external_proprietary.sh index 2bad41011d..9daa8afb72 100644 --- a/src/appMain/core_external_proprietary.sh +++ b/src/appMain/core_external_proprietary.sh @@ -1,27 +1,23 @@ #!/bin/bash cd $(dirname $0) DIR=$(pwd) -PID_DIR=~/.sdl -if [ ! -d "$PID_DIR" ]; then - mkdir $PID_DIR -fi - -CORE_PID_FILE=${PID_DIR}/core.pid -CORE_PROCESS_NAME=SDLCore -PM_PID_FILE=${PID_DIR}/policy_manager.pid +CORE_PID_FILE=${DIR}/core.pid +CORE_APPLICATION_NAME=smartDeviceLinkCore +PM_PID_FILE=${DIR}/policy_manager.pid +PM_APPLICATION_NAME=sample_policy_manager.py function core_start() { if [ -f "$CORE_PID_FILE" ] && [ -n "$(ps -p $(cat $CORE_PID_FILE) -o pid=)" ]; then echo "Core is already running" return 1 - elif [ -n "$(pgrep $CORE_PROCESS_NAME)" ]; then + elif [ -n "$(pgrep -f $CORE_APPLICATION_NAME)" ]; then echo "Core is already running outside of this script" - echo "This lingering instance can be stopped using the \"kill\" command" + echo "All instances of Core can be stopped using the \"kill\" command" return 2 else - echo "Starting SmartDeviceLinkCore" - LD_LIBRARY_PATH=$DIR ${DIR}/smartDeviceLinkCore & + echo "Starting SmartDeviceLink Core" + LD_LIBRARY_PATH=$DIR ${DIR}/${CORE_APPLICATION_NAME} & CORE_PID=$! echo $CORE_PID > $CORE_PID_FILE return 0 @@ -31,7 +27,7 @@ function core_start() { function core_stop() { RESULT=1 if [ -f "$CORE_PID_FILE" ] && [ -n "$(ps -p $(cat $CORE_PID_FILE) -o pid=)" ]; then - echo "Stopping SmartDeviceLinkCore" + echo "Stopping SmartDeviceLink Core" CORE_PID=$(cat $CORE_PID_FILE) kill $CORE_PID @@ -62,10 +58,14 @@ function pm_start() { if [ -f "$PM_PID_FILE" ] && [ -n "$(ps -p $(cat $PM_PID_FILE) -o pid=)" ]; then echo "Policy Server is already running" return 1 + elif [ -n "$(pgrep -f $PM_APPLICATION_NAME)" ]; then + echo "Policy Server is already running outside of this script" + echo "All instances of Core can be stopped using the \"kill\" command" + return 2 else pm_install_dependencies echo "Starting Policy Manager" - python3 ${DIR}/sample_policy_manager.py --pack_port 8088 --unpack_port 8089 --add_http_header --encryption & + python3 ${DIR}/${PM_APPLICATION_NAME} --pack_port 8088 --unpack_port 8089 --add_http_header --encryption & PM_PID=$! echo $PM_PID > $PM_PID_FILE return 0 @@ -88,17 +88,17 @@ function pm_stop() { return $RESULT } -if [ x$1 == xstop ]; then +if [ "$1" == "stop" ]; then core_stop - if [ ! "$?" -eq 0 ]; then + if [ "$?" -ne 0 ]; then echo "Core is not running (or was started outside of this script)" fi pm_stop - if [ ! "$?" -eq 0 ]; then + if [ "$?" -ne 0 ]; then echo "Policy Server is not running (or was started outside of this script)" fi -elif [ x$1 == xrestart ]; then +elif [ "$1" == "restart" ]; then core_stop if [ "$?" -eq 0 ]; then core_start @@ -112,15 +112,20 @@ elif [ x$1 == xrestart ]; then else echo "Policy Server is not running (or was started outside of this script)" fi -elif [ x$1 == xstart ]; then +elif [ "$1" == "start" ]; then core_start pm_start -elif [ x$1 == xkill ]; then +elif [ "$1" == "kill" ]; then core_stop + pkill -9 -f $CORE_APPLICATION_NAME + if [ "$?" -eq 0 ]; then + echo "Killed all lingering instances of SDL Core" + fi + pm_stop - if [ -n "$(pgrep $CORE_PROCESS_NAME)" ]; then - echo "Killing all lingering instances of SDL Core" - killall -9 $CORE_PROCESS_NAME + pkill -9 -f $PM_APPLICATION_NAME + if [ "$?" -eq 0 ]; then + echo "Killed all lingering instances of the Policy Server" fi else echo "usage: core.sh [start/restart/stop/kill]" |