diff --git a/bbb-pre-install.sh b/bbb-pre-install.sh index f55d9a2..5987266 100755 --- a/bbb-pre-install.sh +++ b/bbb-pre-install.sh @@ -130,6 +130,8 @@ detect_os () { DIST="${DIST// /}" DIST_VERSION="${DIST_VERSION// /}" + DIST_VERSION_MAJOR=$(echo $DIST_VERSION | cut -d'.' -f1) + } @@ -555,78 +557,138 @@ echo -e " \033[32mInstall latest version of docker\033[m" echo -e " \033[1m---\033[m" :> "$log_file" -#if ! $(grep -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/sources.list) \ -# && ! $(grep -r -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/sources.list.d/*) -if ! $(grep -r -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/*) -then - blank_line +if [[ ${DIST_VERSION_MAJOR} -lt 22 ]] ; then - echononl "Add GPG key for official Docker repository.." - curl -fsSL https://download.docker.com/linux/ubuntu/gpg 2> "$log_file" | apt-key add - >> "$log_file" 2>&1 + if ! $(grep -r -Eq "^\s*deb\s+.*https://download.docker.com/linux/ubuntu\s+$DIST_CODENAME\s+stable" /etc/apt/*) + then - if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" + blank_line - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/no]: " + echononl "Add GPG key for official Docker repository.." + curl -fsSL https://download.docker.com/linux/ubuntu/gpg 2> "$log_file" | apt-key add - >> "$log_file" 2>&1 + + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user." + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + + + echononl "Add (official) Docker-Repository to APT sources.." + add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${DIST_CODENAME} stable" > "$log_file" 2>&1 + + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + + + echononl "Update repositories.." + apt-get update > "$log_file" 2>&1 + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi else - echo_ok - fi - - - echononl "Add (official) Docker-Repository to APT sources.." - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${DIST_CODENAME} stable" > "$log_file" 2>&1 - - if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/no]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user." - - else - echo_ok - fi - - - echononl "Update repositories.." - apt-get update > "$log_file" 2>&1 - if [[ $? -ne 0 ]]; then - echo_failed - error "$(cat "$log_file")" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/no]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user." - - else - echo_ok + info "Docker repository already present." fi else - info "Docker repository already present." + + echononl "Add GPG key for official Docker repository.." + + if [[ -f "/etc/apt/keyrings/docker.asc" ]] ; then + echo_skipped + else + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc > "$log_file" 2>&1 + + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + + fi + + echononl "Add (official) Docker-Repository to APT sources.." + + tee /etc/apt/sources.list.d/docker.sources < "$log_file" 2>&1 +Types: deb +URIs: https://download.docker.com/linux/ubuntu +Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") +Components: stable +Signed-By: /etc/apt/keyrings/docker.asc +EOF + + if [[ $? -ne 0 ]]; then + echo_failed + error "$(cat "$log_file")" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + else + echo_ok + fi + fi + echononl "Install docker-ce .." if $(dpkg -s docker-ce> /dev/null 2>&1 ) ; then