mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 07:18:36 +00:00
embellish the functions that do initial start and stop of the controller during expressInstall and manually start and stop the router
This commit is contained in:
@@ -67,13 +67,21 @@ function startZitiController {
|
||||
("${ZITI_BIN_DIR-}/ziti-controller" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_RAWNAME}.yaml" > "${log_file}" 2>&1 &)
|
||||
pid=$!
|
||||
echo -e "ziti-controller started as process id: $pid. log located at: $(BLUE "${log_file}")"
|
||||
return $pid
|
||||
echo $pid # for capture by caller
|
||||
}
|
||||
|
||||
function stopZitiController {
|
||||
pkill ziti-controller
|
||||
# shellcheck disable=SC2181
|
||||
if [[ $? == 0 ]]; then echo "Controller stopped."; fi
|
||||
if (( ${#} )); then
|
||||
kill "$1"
|
||||
# shellcheck disable=SC2181
|
||||
if [[ $? == 0 ]]; then
|
||||
echo "Controller stopped."
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
echo "ERROR: need controller PID to kill" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function startExpressEdgeRouter {
|
||||
@@ -81,13 +89,40 @@ function startExpressEdgeRouter {
|
||||
"${ZITI_BIN_DIR}/ziti-router" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${log_file}" 2>&1 &
|
||||
pid=$!
|
||||
echo -e "Express Edge Router started as process id: $pid. log located at: $(BLUE "${log_file}")"
|
||||
return $pid
|
||||
ZITI_EXPRESS_EDGE_ROUTER_PID="$pid"
|
||||
}
|
||||
|
||||
function stopAllEdgeRouters {
|
||||
pkill ziti-router
|
||||
# shellcheck disable=SC2181
|
||||
if [[ $? == 0 ]]; then echo "Router(s) stopped."; fi
|
||||
if [[ -n ${ZITI_EXPRESS_EDGE_ROUTER_PID:-} ]]; then
|
||||
# shellcheck disable=SC2015
|
||||
kill "${ZITI_EXPRESS_EDGE_ROUTER_PID}" && {
|
||||
echo "INFO: stopped router"
|
||||
} || {
|
||||
echo "ERROR: something went wrong with stopping the router(s)" >&2
|
||||
return 1
|
||||
}
|
||||
else
|
||||
if which pkill &>/dev/null; then
|
||||
# shellcheck disable=SC2015
|
||||
pkill ziti-router && {
|
||||
echo "Router(s) stopped."
|
||||
} || {
|
||||
echo "ERROR: something went wrong with stopping the router(s)" >&2
|
||||
return 1
|
||||
}
|
||||
elif which killall &>/dev/null; then
|
||||
# shellcheck disable=SC2015
|
||||
killall ziti-router && {
|
||||
echo "Router(s) stopped."
|
||||
} || {
|
||||
echo "ERROR: something went wrong with stopping the router(s)" >&2
|
||||
return 1
|
||||
}
|
||||
else
|
||||
echo "ERROR: need 'pkill' or 'killall' command to kill routers that were not started with startExpressEdgeRouter" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function checkHostsFile {
|
||||
@@ -484,7 +519,7 @@ function ziti_expressConfiguration {
|
||||
createControllerConfig
|
||||
#createControllerSystemdFile
|
||||
initializeController
|
||||
startZitiController
|
||||
ZITI_EXPRESS_CONTROLLER_PID=$(startZitiController)
|
||||
echo "waiting for the controller to come online to allow the edge router to enroll"
|
||||
|
||||
waitForController
|
||||
@@ -518,7 +553,7 @@ function ziti_expressConfiguration {
|
||||
"${ZITI_BIN_DIR-}/ziti-router" enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log"
|
||||
echo ""
|
||||
|
||||
stopZitiController
|
||||
[[ -n ${ZITI_EXPRESS_CONTROLLER_PID:-} ]] && stopZitiController "${ZITI_EXPRESS_CONTROLLER_PID}"
|
||||
echo "Edge Router enrolled. Controller stopped."
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user