armbian-next: cli: try (and fail, probably...) to be helpful with half-working Docker installs

This commit is contained in:
Ricardo Pardini 2023-01-29 18:24:14 +01:00
parent d43c4262b0
commit 281e3f0828
No known key found for this signature in database
GPG Key ID: 3D38CA12A66C5D02
2 changed files with 20 additions and 4 deletions

View File

@ -192,7 +192,7 @@ function produce_relaunch_parameters() {
}
function cli_standard_relaunch_docker_or_sudo() {
display_alert "Gonna relaunch" "EUID: ${EUID} -- PREFER_DOCKER:${PREFER_DOCKER}" "warn"
display_alert "Gonna relaunch" "EUID: ${EUID} -- PREFER_DOCKER:${PREFER_DOCKER}" "debug"
if [[ "${EUID}" == "0" ]]; then # we're already root. Either running as real root, or already sudo'ed.
if [[ "${ARMBIAN_RELAUNCHED}" != "yes" && "${ALLOW_ROOT}" != "yes" ]]; then
display_alert "PROBLEM: don't run ./compile.sh as root or with sudo" "PROBLEM: don't run ./compile.sh as root or with sudo" "err"
@ -215,12 +215,21 @@ function cli_standard_relaunch_docker_or_sudo() {
if [[ "${DOCKER_INFO_OK}" == "yes" ]]; then
if [[ "${PREFER_DOCKER:-yes}" == "yes" ]]; then
display_alert "Trying to build, not root, but Docker is ready to go" "delegating to Docker" "debug"
display_alert "not root, but Docker is ready to go" "delegating to Docker" "debug"
ARMBIAN_CHANGE_COMMAND_TO="docker"
ARMBIAN_CLI_RELAUNCH_COMMAND="${ARMBIAN_COMMAND}" # add params when relaunched under docker
return 0
else
display_alert "Trying to build, not root, but Docker is ready to go" "but PREFER_DOCKER is set to 'no', so can't use it" "warn"
display_alert "not root, but Docker is ready to go" "but PREFER_DOCKER is set to 'no', so can't use it" "warn"
fi
else
if [[ "${DOCKER_IN_PATH:-no}" == "yes" ]]; then
if [[ "${PREFER_DOCKER:-yes}" == "no" ]]; then
: # congrats, don't have it, didn't wanna it.
else
display_alert "Docker is installed, but not usable" "can't use Docker; check your Docker config / groups / etc" "warn"
exit_if_countdown_not_aborted 10 "Docker installed but not usable"
fi
fi
fi

View File

@ -32,6 +32,14 @@ function check_and_install_docker_daemon() {
function get_docker_info_once() {
if [[ -z "${DOCKER_INFO}" ]]; then
declare -g DOCKER_INFO
declare -g DOCKER_IN_PATH="no"
# if "docker" is in the PATH...
if [[ -n "$(command -v docker)" ]]; then
display_alert "Docker is in the path" "Docker in PATH" "warn"
DOCKER_IN_PATH="yes"
fi
# Shenanigans to go around error control & capture output in the same effort.
DOCKER_INFO="$({ docker info 2> /dev/null && echo "DOCKER_INFO_OK"; } || true)"
declare -g -r DOCKER_INFO="${DOCKER_INFO}" # readonly
@ -199,7 +207,6 @@ function docker_cli_prepare() {
display_alert "Docker info" "Docker ${DOCKER_SERVER_VERSION} Kernel:${DOCKER_SERVER_KERNEL_VERSION} RAM:${DOCKER_SERVER_TOTAL_RAM} CPUs:${DOCKER_SERVER_CPUS} OS:'${DOCKER_SERVER_OS}' hostname '${DOCKER_SERVER_NAME_HOST}' under '${DOCKER_ARMBIAN_HOST_OS_UNAME}' - buildx:${DOCKER_HAS_BUILDX} - loop-hacks:${DOCKER_SERVER_REQUIRES_LOOP_HACKS} static-loops:${DOCKER_SERVER_USE_STATIC_LOOPS}" "sysinfo"
}
function docker_cli_prepare_dockerfile() {
# @TODO: grab git info, add as labels et al to Docker... (already done in GHA workflow)