[infrastructure] Better support for atomic distros in install.sh, docker fixes in getting-started.sh (#6139)
* Made the docker check first for getting-started.sh, better atomic support for install.sh * Check for docker socket perms * Added fallback for systems without rpm-ostree or bootc. * macOS fix for docker socket check * Change error message for docker group. No longer using a blanket recommendation for the docker group.
This commit is contained in:
@@ -19,6 +19,46 @@ readonly MSG_SEPARATOR="=========================================="
|
|||||||
# Utility Functions
|
# Utility Functions
|
||||||
############################################
|
############################################
|
||||||
|
|
||||||
|
check_docker_sock_perms() {
|
||||||
|
local sock="${DOCKER_HOST:-unix:///var/run/docker.sock}"
|
||||||
|
sock="${sock#unix://}"
|
||||||
|
|
||||||
|
if [[ ! -S "$sock" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -r "$sock" ]] || [[ ! -w "$sock" ]]; then
|
||||||
|
local group
|
||||||
|
if [[ "${OSTYPE}" == "darwin"* ]]; then
|
||||||
|
group="$(stat -f '%Sg' "$sock")"
|
||||||
|
else
|
||||||
|
group="$(stat -c '%G' "$sock")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cannot access Docker socket: $sock" > /dev/stderr
|
||||||
|
echo "" > /dev/stderr
|
||||||
|
echo "Socket permissions:" > /dev/stderr
|
||||||
|
ls -l "$sock" > /dev/stderr
|
||||||
|
echo "" > /dev/stderr
|
||||||
|
|
||||||
|
if [[ "$group" == "docker" ]]; then
|
||||||
|
echo "Your user may need to be added to the '$group' group:" > /dev/stderr
|
||||||
|
echo " sudo usermod -aG $group \"$USER\"" > /dev/stderr
|
||||||
|
echo "Then log out and back in, or run this for the current shell:" > /dev/stderr
|
||||||
|
echo " newgrp $group" > /dev/stderr
|
||||||
|
echo "Note: newgrp is temporary; usermod is the permanent group change." > /dev/stderr
|
||||||
|
else
|
||||||
|
echo "The Docker socket is owned by the '$group' group, which is not the standard 'docker' group." > /dev/stderr
|
||||||
|
echo "For safety, this script will not suggest adding your user to '$group'." > /dev/stderr
|
||||||
|
echo "Instead, either run this script with appropriate privileges (for example, via sudo) or follow Docker's post-install steps to configure access via the 'docker' group:" > /dev/stderr
|
||||||
|
echo " https://docs.docker.com/engine/install/linux-postinstall/" > /dev/stderr
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
check_docker_compose() {
|
check_docker_compose() {
|
||||||
if command -v docker-compose &> /dev/null
|
if command -v docker-compose &> /dev/null
|
||||||
then
|
then
|
||||||
@@ -581,12 +621,15 @@ start_services_and_show_instructions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_environment() {
|
init_environment() {
|
||||||
|
# Check if docker compose is installed using check_docker_compose function
|
||||||
|
DOCKER_COMPOSE_COMMAND=$(check_docker_compose)
|
||||||
|
check_docker_sock_perms
|
||||||
|
|
||||||
initialize_default_values
|
initialize_default_values
|
||||||
configure_domain
|
configure_domain
|
||||||
configure_reverse_proxy
|
configure_reverse_proxy
|
||||||
|
|
||||||
check_jq
|
check_jq
|
||||||
DOCKER_COMPOSE_COMMAND=$(check_docker_compose)
|
|
||||||
|
|
||||||
check_existing_installation
|
check_existing_installation
|
||||||
generate_configuration_files
|
generate_configuration_files
|
||||||
|
|||||||
@@ -417,15 +417,30 @@ if type uname >/dev/null 2>&1; then
|
|||||||
# Check the availability of a compatible package manager
|
# Check the availability of a compatible package manager
|
||||||
if check_use_bin_variable; then
|
if check_use_bin_variable; then
|
||||||
PACKAGE_MANAGER="bin"
|
PACKAGE_MANAGER="bin"
|
||||||
|
elif [ -e /run/ostree-booted ]; then
|
||||||
|
if [ -x "$(command -v rpm-ostree)" ]; then
|
||||||
|
PACKAGE_MANAGER="rpm-ostree"
|
||||||
|
echo "The installation will be performed using rpm-ostree package manager"
|
||||||
|
elif [ -x "$(command -v bootc)" ]; then
|
||||||
|
echo "Detected bootc system without rpm-ostree." >&2
|
||||||
|
echo "NetBird cannot be installed via package manager on this system." >&2
|
||||||
|
echo "Options:" >&2
|
||||||
|
echo " 1. Install via Distrobox (instructions in the installation docs)" >&2
|
||||||
|
echo " 2. Rebuild your base image with rpm-ostree included" >&2
|
||||||
|
echo " 3. Bake NetBird into your Containerfile" >&2
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Detected ostree-booted system without rpm-ostree or bootc." >&2
|
||||||
|
echo "NetBird cannot be installed automatically on this atomic system." >&2
|
||||||
|
echo "Please install NetBird by rebuilding your base image or use a supported package manager." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
elif [ -x "$(command -v apt-get)" ]; then
|
elif [ -x "$(command -v apt-get)" ]; then
|
||||||
PACKAGE_MANAGER="apt"
|
PACKAGE_MANAGER="apt"
|
||||||
echo "The installation will be performed using apt package manager"
|
echo "The installation will be performed using apt package manager"
|
||||||
elif [ -x "$(command -v dnf)" ]; then
|
elif [ -x "$(command -v dnf)" ]; then
|
||||||
PACKAGE_MANAGER="dnf"
|
PACKAGE_MANAGER="dnf"
|
||||||
echo "The installation will be performed using dnf package manager"
|
echo "The installation will be performed using dnf package manager"
|
||||||
elif [ -x "$(command -v rpm-ostree)" ]; then
|
|
||||||
PACKAGE_MANAGER="rpm-ostree"
|
|
||||||
echo "The installation will be performed using rpm-ostree package manager"
|
|
||||||
elif [ -x "$(command -v yum)" ]; then
|
elif [ -x "$(command -v yum)" ]; then
|
||||||
PACKAGE_MANAGER="yum"
|
PACKAGE_MANAGER="yum"
|
||||||
echo "The installation will be performed using yum package manager"
|
echo "The installation will be performed using yum package manager"
|
||||||
|
|||||||
Reference in New Issue
Block a user