Skip to content

Commit d300450

Browse files
authored
Merge pull request #7 from codice/base-updates
updates to lna function to avoid race condition when checking active …
2 parents 4a9c29e + 4398734 commit d300450

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

entrypoint/global_env.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,22 @@ function isReady {
108108
fi
109109
return 0
110110
else
111-
if [ $(${_client} "lna" | tail -n +6 | grep -Ev "${_legacy_wfr_exclusions}" | wc -l | awk '{$1=$1};1') != "0" ]; then
111+
# Run client command using piped input (more reliable than command-line args)
112+
# The client with command-line args can return "Closed" even when ready
113+
local client_output
114+
client_output=$(echo "lna" | ${_client} 2>&1)
115+
local client_exit_code=$?
116+
117+
# If client command failed, system is not ready
118+
if [ ${client_exit_code} -ne 0 ]; then
119+
return 1
120+
fi
121+
122+
# Check if there are any bundles not active (excluding known exclusions)
123+
# First grep for actual bundle rows with "Resolved" state, then exclude known fragments
124+
local resolved_bundles
125+
resolved_bundles=$(echo "${client_output}" | grep "│ Resolved │" | grep -Ev "${_legacy_wfr_exclusions}" | wc -l | awk '{$1=$1};1')
126+
if [ "${resolved_bundles}" != "0" ]; then
112127
return 1
113128
fi
114129
return 0

entrypoint/post_start.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ echo -e "\nLog file found, continuing..."
1313
waitForReady
1414

1515
if [ -n "$INSTALL_PROFILE" ]; then
16-
echo "Installing $INSTALL_PROFILE profile. This may take some time..."
17-
${_client} profile:install ${INSTALL_PROFILE}
16+
echo "Installing $INSTALL_PROFILE profile. This may take some time..."
17+
echo "profile:install ${INSTALL_PROFILE}" | ${_client}
1818
waitForReady
1919
fi
2020

@@ -24,7 +24,7 @@ if [ -n "$INSTALL_FEATURES" ]; then
2424
for index in "${!_install_features[@]}"
2525
do
2626
echo "Installing: ${_install_features[$index]}"
27-
${_client} "feature:install ${_install_features[$index]}"
27+
echo "feature:install ${_install_features[$index]}" | ${_client}
2828
done
2929
fi
3030

@@ -34,7 +34,7 @@ if [ -n "$UNINSTALL_FEATURES" ]; then
3434
for index in "${!_uninstall_features[@]}"
3535
do
3636
echo "Uninstalling: ${_uninstall_features[$index]}"
37-
${_client} "feature:uninstall ${_uninstall_features[$index]}"
37+
echo "feature:uninstall ${_uninstall_features[$index]}" | ${_client}
3838
done
3939
fi
4040

0 commit comments

Comments
 (0)