Skip to content

Commit

Permalink
init/export: check if we're in a container earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
89luca89 committed Dec 12, 2021
1 parent ff519d1 commit 7c31836
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ while :; do
break ;;
esac
done

# Also check we're running inside a container and not on the host
if [ ! -f /run/.containerenv ]; then
printf >&2 "You must run %s inside a container!\n" " $(basename "$0")"
exit 126
fi

# Ensure the foundamental variables are set and not empty, we will not proceed if
# they are not all set.
if [ -z "${exported_app}" ] &&
Expand All @@ -190,12 +197,6 @@ if [ -n "${exported_bin}" ] && [ -z "${dest_path}" ]; then
exit 2
fi

# Also check we're running inside a container and not on the host
if [ ! -f /run/.containerenv ]; then
printf >&2 "You must run %s inside a container...\n" " $(basename "$0")"
exit 126
fi

set -o errexit
set -o nounset
# set verbosity
Expand Down
13 changes: 7 additions & 6 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,20 @@ while :; do
esac
done

# Also check we're running inside a container and not on the host
if [ ! -f /run/.containerenv ]; then
printf >&2 "You must run %s inside a container!\n" " $(basename "$0")"
printf >&2 "distrobox-init should only be used as an entrypoint for a distrobox!\n"
exit 126
fi

# Ensure the foundamental variables are set and not empty, we will not proceed if
# they are not all set.
[ -z "${container_user_name}" ] && printf >&2 "Invalid arguments, missing username\n" && exit 2
[ -z "${container_user_uid}" ] && printf >&2 "Invalid arguments, missing user uid\n" && exit 2
[ -z "${container_user_gid}" ] && printf >&2 "Invalid arguments, missing user gud\n" && exit 2
[ -z "${container_user_home}" ] && printf >&2 "Invalid argument, missing user home\n" && exit 2

# Also check we're running inside a container and not on the host
if [ ! -f /run/.containerenv ]; then
printf >&2 "You must run %s inside a container...\n" " $(basename "$0")"
exit 126
fi

set -o errexit
set -o nounset
# set verbosity
Expand Down

0 comments on commit 7c31836

Please sign in to comment.