Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
travier committed Jul 22, 2022
1 parent 189c778 commit 0e7f648
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rhcos-toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ setup() {
}

run() {
# Pull the container image if it does not exists yet
if ! image_exists; then
image_pull
if container_exists; then
sudo podman rm "${TOOLBOX_NAME}"
fi
# If it already exists, make sure it is up-to-date
elif ! image_fresh; then
>&2 read -r -p "There is a newer version of ${TOOLBOX_IMAGE} available. Would you like to pull it? [y/N] "
if [[ ${REPLY} =~ ^([Yy][Ee][Ss]|[Yy])+$ ]]; then
Expand All @@ -41,6 +43,8 @@ run() {
fi
fi

# If the container does not already exists, create it, while making sure to
# use the option from the RUN label if provided
local runlabel=$(image_runlabel)
if ! container_exists; then
errecho "Spawning a container '${TOOLBOX_NAME}' with image '${TOOLBOX_IMAGE}'"
Expand All @@ -55,6 +59,7 @@ run() {
errecho "(To remove the container and start with a fresh toolbox, run: sudo podman rm '${TOOLBOX_NAME}')"
fi

# Start our freshly created container
local state=$(container_state)
if [[ "${state}" == configured ]] || [[ "${state}" == created ]] || [[ "${state}" == exited ]] || [[ "${state}" == stopped ]]; then
container_start
Expand All @@ -66,6 +71,8 @@ run() {
if [[ "$#" -eq "0" ]]; then
errecho "Container started successfully. To exit, type 'exit'."
fi
# Attach to the interactive shell in the container or directly execute the
# command passed as argument
container_exec "$@"
}

Expand Down

0 comments on commit 0e7f648

Please sign in to comment.