diff --git a/install/docker-install.sh b/install/docker-install.sh index e5353b7..b6b970d 100644 --- a/install/docker-install.sh +++ b/install/docker-install.sh @@ -164,14 +164,21 @@ setup_docker_repo() { # Set proper permissions sudo chmod a+r /etc/apt/keyrings/docker.gpg + # Remove any existing Docker repository file + sudo rm -f /etc/apt/sources.list.d/docker.list + # Create the repository configuration with error handling - local repo_config="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$ID $VERSION_CODENAME stable" + local repo_config="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" if ! echo "$repo_config" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; then echo -e "Failed to create repository configuration $CROSS_MARK" return 1 fi + # Display the repository configuration for verification + echo "Created repository configuration:" + cat /etc/apt/sources.list.d/docker.list + # Verify the repository file exists and has content if [ ! -s /etc/apt/sources.list.d/docker.list ]; then echo -e "Repository configuration file is empty or missing $CROSS_MARK" @@ -219,6 +226,14 @@ setup_docker_user() { fi } +# Function to clean up in case of failure +cleanup_repo() { + echo "Cleaning up repository files..." + sudo rm -f /etc/apt/sources.list.d/docker.list + sudo rm -f /etc/apt/keyrings/docker.gpg + echo -e "Repository cleanup completed $CHECK_MARK" +} + # Remove the script itself remove_script() { if [ -f "$0" ]; then @@ -264,6 +279,7 @@ if ! format_output install_dependencies "Installing Dependencies"; then fi if ! format_output setup_docker_repo "Setting up Docker Repository"; then + format_output cleanup_repo "Cleaning up failed repository setup" success=1 exit $success fi