Refactored 'waCheckContainerRunning' in 'installer.sh' to fix #157.

This commit is contained in:
Rohan Barar 2024-07-24 02:39:57 +10:00
parent 7329ef9a99
commit 25b241b12d

View File

@ -800,7 +800,7 @@ function waCheckVMRunning() {
} }
# Name: 'waCheckContainerRunning' # Name: 'waCheckContainerRunning'
# Role: Throw an error if the Docker container is not running. # Role: Throw an error if the Docker/Podman container is not running.
function waCheckContainerRunning() { function waCheckContainerRunning() {
# Print feedback. # Print feedback.
echo -n "Checking container status... " echo -n "Checking container status... "
@ -808,13 +808,9 @@ function waCheckContainerRunning() {
# Declare variables. # Declare variables.
local CONTAINER_STATE="" local CONTAINER_STATE=""
# Determine container state (docker). if [[ "$WAFLAVOR" == "docker" ]]; then
if command -v docker &>/dev/null; then
CONTAINER_STATE=$(docker ps --filter name="WinApps" --format '{{.Status}}') CONTAINER_STATE=$(docker ps --filter name="WinApps" --format '{{.Status}}')
fi elif [[ "$WAFLAVOR" == "podman" ]]; then
# Determine container state (podman).
if [ -z "$CONTAINER_STATE" ]; then
CONTAINER_STATE=$(podman ps --filter name="WinApps" --format '{{.Status}}') CONTAINER_STATE=$(podman ps --filter name="WinApps" --format '{{.Status}}')
fi fi
@ -827,7 +823,7 @@ function waCheckContainerRunning() {
echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n" echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n"
# Display the error type. # Display the error type.
echo -e "${ERROR_TEXT}ERROR:${CLEAR_TEXT} ${BOLD_TEXT}DOCKER CONTAINER NOT RUNNING.${CLEAR_TEXT}" echo -e "${ERROR_TEXT}ERROR:${CLEAR_TEXT} ${BOLD_TEXT}CONTAINER NOT RUNNING.${CLEAR_TEXT}"
# Display the error details. # Display the error details.
echo -e "${INFO_TEXT}Windows is not running.${CLEAR_TEXT}" echo -e "${INFO_TEXT}Windows is not running.${CLEAR_TEXT}"
@ -835,7 +831,8 @@ function waCheckContainerRunning() {
# Display the suggested action(s). # Display the suggested action(s).
echo "--------------------------------------------------------------------------------" echo "--------------------------------------------------------------------------------"
echo "Please ensure Windows is powered on:" echo "Please ensure Windows is powered on:"
echo -e "${COMMAND_TEXT}docker compose start${CLEAR_TEXT}" echo -e "${COMMAND_TEXT}docker compose --file ~/.config/winapps/winapps.conf start${CLEAR_TEXT} # Docker"
echo -e "${COMMAND_TEXT}podman-compose --file ~/.config/winapps/winapps.conf start${CLEAR_TEXT} # Podman"
echo "--------------------------------------------------------------------------------" echo "--------------------------------------------------------------------------------"
# Terminate the script. # Terminate the script.