Skip to content

Add retry logic to add-apt-repository for transient DNS failures #1

@hello-binit

Description

@hello-binit

[MODIFY] stretch_install_system.sh

Wrap the add-apt-repository calls (lines 18–19) with a retry helper:

+function retry_cmd {
+    local max_attempts=3
+    local delay=5
+    local attempt=1
+    while true; do
+        "$@" && return 0
+        if (( attempt >= max_attempts )); then
+            echo "ERROR: Command failed after $max_attempts attempts: $*"
+            return 1
+        fi
+        echo "Attempt $attempt failed. Retrying in ${delay}s..."
+        sleep $delay
+        ((attempt++))
+        ((delay *= 2))
+    done
+}
+
 echo "Apt update & upgrade (this might take a while)"
-sudo apt-add-repository universe -y >> $REDIRECT_LOGFILE
-sudo add-apt-repository -y ppa:kobuk-team/intel-graphics >> $REDIRECT_LOGFILE
+retry_cmd sudo apt-add-repository universe -y >> $REDIRECT_LOGFILE
+retry_cmd sudo add-apt-repository -y ppa:kobuk-team/intel-graphics >> $REDIRECT_LOGFILE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions