Make script wait for NM to start
NOMACHINE_INSTALL_TASK="NoMachineInitialization"
NM_TARGET_VERSION="${CP_CAP_DESKTOP_NM_VERSION:-6.5.6-9}"
+CP_NM_WAIT_TIMEOUT="${CP_NM_WAIT_TIMEOUT:-10}"
export CP_NM_NOMACHINE_PORT="${CP_NM_NOMACHINE_PORT:-4000}"
export CP_NM_LOCAL_PORT="${CP_NM_LOCAL_PORT:-8089}"
@@ -236,13 +237,29 @@ if [ $? -ne 0 ]; then
exit 1
else
sleep 5
+ _started=0
+ for _nm_iter in $(seq 1 $CP_NM_WAIT_TIMEOUT); do
lsof -i:${CP_NM_NOMACHINE_PORT} | grep LISTEN > /dev/null
- if [ $? -ne 0 ]; then
+ if [ $? -eq 0 ]; then
+ _started=1
+ break
+ fi
+ sleep 1
+ done
+ if [ $_started -eq 0 ]; then
pipe_log_fail "NM service is not active on port $CP_NM_NOMACHINE_PORT" "$NOMACHINE_INSTALL_TASK"
exit 1
fi
+ _started=0
+ for _nm_iter in $(seq 1 $CP_NM_WAIT_TIMEOUT); do
lsof -i:${CP_NM_LOCAL_PORT} | grep LISTEN > /dev/null
- if [ $? -ne 0 ]; then
+ if [ $? -eq 0 ]; then
+ _started=1
+ break
+ fi
+ sleep 1
+ done
+ if [ $_started -eq 0 ]; then
pipe_log_fail "NM service is not available on port $CP_NM_LOCAL_PORT" "$NOMACHINE_INSTALL_TASK"
exit 1
fi
