Skip to content

Commit

Permalink
service: Running port check only on {start, console}
Browse files Browse the repository at this point in the history
By a mistake I moved the port check to the general function.
Thus, when stopping openHAB, a error message was shown, which tells that the ports are already in use.
By now checking the port is only done, when starting openHAB as a service or in console mode.

Signed-off-by: Thomas Karl Pietrowski <thopiekar@gmail.com> (github: thopiekar)
  • Loading branch information
thopiekar committed May 6, 2017
1 parent 2c48a83 commit 0a3fb23
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shared/openHAB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,16 @@ function setupEnvironment {
OPENHAB_HTTPS_PORT=${QPKG_HTTPS_PORT}
log_tool -t 1 -a "Your http port definition is fautly. Using default ${OPENHAB_HTTPS_PORT} instead!"
fi
echo "* Note: OPENHAB_HTTP_PORT="$OPENHAB_HTTP_PORT
echo "* Note: OPENHAB_HTTPS_PORT="$OPENHAB_HTTPS_PORT
}

function checkPorts {
# Are the ports already used?
if lsof -Pi :${OPENHAB_HTTP_PORT} -sTCP:LISTEN -t > /dev/null && lsof -Pi :${OPENHAB_HTTPS_PORT} -sTCP:LISTEN -t > /dev/null; then
log_tool -t 1 -a "Port ${OPENHAB_HTTP_PORT} or ${OPENHAB_HTTPS_PORT} already in use."
exit 1
fi


}

case "$1" in
Expand All @@ -163,6 +165,7 @@ case "$1" in
fi

setupEnvironment
checkPorts

# # Is there a pidfile?
# if [ -f ${QPKG_PIDFILE} ]; then
Expand Down Expand Up @@ -239,6 +242,8 @@ ${QPKG_STATUS} status

console)
setupEnvironment
checkPorts

cd ${QPKG_DISTRIBUTION} && JAVA_HOME=${JAVA_HOME} PATH=$PATH:${JAVA_HOME}/bin OPENHAB_HTTP_PORT=${QPKG_HTTP_PORT} OPENHAB_HTTPS_PORT=${QPKG_HTTPS_PORT} ${QPKG_CONSOLE}
;;

Expand Down

0 comments on commit 0a3fb23

Please sign in to comment.