Skip to content

Commit

Permalink
rm: add fallback value to response_force
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Jun 20, 2024
1 parent b2370e6 commit b8e315d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion distrobox-rm
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ for container in ${container_name_list}; do
fi

# Accept only y,Y,Yes,yes,n,N,No,no.
case "${response_force}" in
case "${response_force:-"N"}" in
y | Y | Yes | yes | YES)
force=1
force_flag="--force"
Expand Down
24 changes: 8 additions & 16 deletions extras/podman-host
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

echo "$@" >> /home/luca-linux/logs.log

id="$(echo "$@" | grep -Eo ' [a-zA-Z0-9]{64} ' | tr -d ' ')"
PODMAN_COMMAND="$(command -v podman 2> /dev/null)"
DISTROBOX_COMMAND="$(command -v distrobox 2> /dev/null)"
Expand All @@ -21,27 +23,16 @@ if echo "$@" | grep -q 'exec'; then
# if exec && distrobox -> use distrobox-enter --
if [ "$(${PODMAN_COMMAND} inspect --type container --format '{{ index .Config.Labels "manager" }}' "${id}")" = "distrobox" ]; then

# Ensure that our distrobox containers will use different vscode-servers by symlinking to different paths
if [ -n "${id}" ]; then
# shellcheck disable=SC2016
${PODMAN_COMMAND} exec -u "${USER}" "${id}" /bin/sh -c '
if [ ! -L "${HOME}/.vscode-server" ]; then
[ -e "${HOME}/.vscode-server" ] && mv "${HOME}/.vscode-server" /var/tmp
[ -d /var/tmp/.vscode-server ] && mkdir /var/tmp/.vscode-server
ln -sf /var/tmp/.vscode-server "$HOME"
elif [ ! -e "${HOME}/.vscode-server" ]; then
mkdir /var/tmp/.vscode-server
fi
'
fi

# Remove everything from $@ and leave only the execution part, we start
# capturing after we meet our ID
dbox_args="-e A=B"
dbox_args="-e VSCODE_AGENT_FOLDER=/var/tmp/.vscode-server"
capture="false"
for i; do
if [ "${capture}" = "true" ]; then
set -- "$@" "${i}"
# set -- "$@" "${i}"
set -- "$@" "$(echo "${i}" | sed "s|${HOME}|/var/tmp|g")"
elif echo "${i}" | grep -q "${HOME}"; then
dbox_args="${dbox_args} -e $(echo "${i}" | sed "s|${HOME}|/var/tmp|g")"
elif echo "${i}" | grep -q "VSCODE"; then
dbox_args="${dbox_args} -e ${i}"
elif echo "${i}" | grep -q "\-w"; then
Expand All @@ -53,6 +44,7 @@ if echo "$@" | grep -q 'exec'; then
shift
done

echo AAAAAAAAAAAAAAAAA ${DISTROBOX_COMMAND} enter --additional-flags "${dbox_args}" "${id}" -- "$@" >> /home/luca-linux/logs.log
${DISTROBOX_COMMAND} enter --additional-flags "${dbox_args}" "${id}" -- "$@"
exit $?
fi
Expand Down

0 comments on commit b8e315d

Please sign in to comment.