From bcc05b2d7004e1dcfcdfbd89f4ec502821d97f8e Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Fri, 27 Feb 2026 09:35:02 +0100 Subject: [PATCH 01/19] Add macOS compatibility for DAppNode profile and improve alias handling (#692) --- .dappnode_profile | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/.dappnode_profile b/.dappnode_profile index baefcefe..538e868f 100755 --- a/.dappnode_profile +++ b/.dappnode_profile @@ -18,31 +18,50 @@ export HTTPS_VERSION="${HTTPS:-0.2.2}" export DAPPNODE_DIR="/usr/src/dappnode" export DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE" +# macOS host-mode helpers (this file is often sourced in a shell) +if [ "$(uname -s 2>/dev/null)" = "Darwin" ]; then + export DISABLE_HOST_SCRIPTS="${DISABLE_HOST_SCRIPTS:-true}" + + for user_home in /Users/*; do + [ -d "$user_home" ] || continue + [ -d "$user_home/dappnode/DNCORE" ] || continue + export DAPPNODE_DIR="$user_home/dappnode" + export DAPPNODE_CORE_DIR="$user_home/dappnode/DNCORE" + break + done +fi + #!ISOBUILD Do not modify, variables above imported for ISO build -DNCORE_YMLS=$(find $DAPPNODE_CORE_DIR -name "docker-compose-*.yml" -printf "-f %p ") -# shellcheck disable=SC2207 -# shellcheck disable=SC2034 -DNCORE_YMLS_ARRAY=($(find /usr/src/dappnode/DNCORE -name "docker-compose-*.yml" | sort)) + +DNCORE_YMLS="" +if [ -d "$DAPPNODE_CORE_DIR" ]; then + DNCORE_YMLS=$(find "$DAPPNODE_CORE_DIR" -name "docker-compose-*.yml" -print | sort | sed 's|^|-f |' | tr '\n' ' ') +fi # Returns docker core containers status -alias dappnode_status='docker compose $DNCORE_YMLS ps' -# Stop docker core containers -alias dappnode_stop='docker compose $DNCORE_YMLS stop && docker stop $(docker container ls -a -q -f name=DAppNode*)' -# Start docker core containers -alias dappnode_start='docker compose $DNCORE_YMLS up -d && docker start $(docker container ls -a -q -f name=DAppNode*)' -# Remove docker core containers. This does not remove named volumes -alias dappnode_down='docker compose $DNCORE_YMLS down' +# NOTE: zsh does not word-split `$DNCORE_YMLS` by default, so use `${=DNCORE_YMLS}` there. +if [ -n "${ZSH_VERSION:-}" ]; then + alias dappnode_status='docker compose ${=DNCORE_YMLS} ps' + alias dappnode_stop='docker compose ${=DNCORE_YMLS} stop && docker stop $(docker container ls -a -q -f name=DAppNode*)' + alias dappnode_start='docker compose ${=DNCORE_YMLS} up -d && docker start $(docker container ls -a -q -f name=DAppNode*)' + alias dappnode_down='docker compose ${=DNCORE_YMLS} down' +else + alias dappnode_status='docker compose $DNCORE_YMLS ps' + alias dappnode_stop='docker compose $DNCORE_YMLS stop && docker stop $(docker container ls -a -q -f name=DAppNode*)' + alias dappnode_start='docker compose $DNCORE_YMLS up -d && docker start $(docker container ls -a -q -f name=DAppNode*)' + alias dappnode_down='docker compose $DNCORE_YMLS down' +fi # Return open-vpn credentials from a specific user. e.g: dappnode_get dappnode_admin alias dappnode_openvpn_get='docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get' # Return open-vpn admin credentials alias dappnode_openvpn='docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth getAdminCredentials' # Return wifi credentials (ssid and password) -alias dappnode_wifi='cat /usr/src/dappnode/DNCORE/docker-compose-wifi.yml | grep "SSID\|WPA_PASSPHRASE"' +alias dappnode_wifi='cat "$DAPPNODE_CORE_DIR/docker-compose-wifi.yml" | grep "SSID\|WPA_PASSPHRASE"' # Return remote credentials in plain text. OPTIONS: # --qr (QR format). --local (local creds for NAT loopback issues) alias dappnode_wireguard='docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials' # Execute access_credentials.sh script to check for connectivity methods -alias dappnode_connect='/usr/bin/bash /usr/src/dappnode/scripts/dappnode_access_credentials.sh' +alias dappnode_connect='/usr/bin/bash "$DAPPNODE_DIR/scripts/dappnode_access_credentials.sh"' # Return all available commands alias dappnode_help='echo -e "\n\tDAppNode commands available:\n\n\tdappnode_help\t\tprints out this message\n\n\tdappnode_wifi\t\tget wifi credentials (SSID and password)\n\n\tdappnode_openvpn\tget Open VPN credentials\n\n\tdappnode_wireguard\tget Wireguard VPN credentials (dappnode_wireguard --help for more info)\n\n\tdappnode_connect\tcheck connectivity methods available in DAppNode\n\n\tdappnode_status\t\tget status of dappnode containers\n\n\tdappnode_start\t\tstart dappnode containers\n\n\tdappnode_stop\t\tstop dappnode containers\n"' # Compose alias for backward compatibility From dcd2e8614d8626e6b22e9cc32cefbf9bbaa3e87a Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Fri, 27 Feb 2026 11:17:37 +0100 Subject: [PATCH 02/19] Add linter CI to profile script (#693) * Add macOS compatibility for DAppNode profile and improve alias handling * Add shell compatibility checks for .dappnode_profile in CI workflow * Update actions/checkout to v6 in linter workflow --- .github/workflows/linter.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 58b25b85..0307d510 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 @@ -33,3 +33,33 @@ jobs: FILTER_REGEX_EXCLUDE: .github/* DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + shell-compat: + name: Shell compatibility (.dappnode_profile) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - name: Checkout Code + uses: actions/checkout@v6 + + - name: Install zsh (Ubuntu) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y zsh + + - name: Parse check (bash) + run: bash -n .dappnode_profile + + - name: Parse check (zsh) + run: zsh -n .dappnode_profile + + - name: Source check (bash) + run: bash -lc 'set -euo pipefail; source ./.dappnode_profile' + + - name: Source check (zsh) + run: zsh -lc 'set -e; source ./.dappnode_profile; alias dappnode_status >/dev/null' From ce00ffae38297975c0b913c2b4af3e204ca38906 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Mon, 9 Mar 2026 09:19:05 +0100 Subject: [PATCH 03/19] Enhance macOS compatibility in installation script (#694) * Enhance macOS compatibility in installation script - Added checks to ensure the script is executed, not sourced. - Improved OS detection and handling for macOS and Linux. - Updated directory paths for macOS. - Introduced cross-platform helper functions for downloading files and modifying files. - Added functionality to patch the .dappnode_profile for macOS compatibility. - Enhanced user shell configuration to source the profile correctly. - Cleaned up rc.local for Linux installations. - Improved logging and user feedback during installation. * Add macOS support for installation scripts and update DAppNode core start function * Normalize component names to lowercase in download URL and file paths * Update macOS test script to install Docker using Homebrew * Normalize component names to lowercase in Docker image loading logic * Remove macOS test scripts from workflow configuration * Update IPFS endpoint and enhance logging in installation script * Refactor logging in installation script to remove color output and improve readability * uninstall script in macos (#695) * uninstall script in macos * comment reexec under bash * comment * remove colors logic --------- Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> * Enhance installation script with improved error handling, logging, and CLI wrappers for VPN commands * Remove core CLI wrappers from installation script to streamline execution * Add macOS-specific environment variable injection for dappmanager compose * Fix DISABLE_HOST_SCRIPTS environment variable handling in macOS patch function * Initialize DNCORE_COMPOSE_ARGS array to prevent unbound variable errors * Refactor macOS patch function to handle environment variable insertion with temporary file for compatibility * Increase sleep duration to 30 seconds for VPN initialization in installation script * Implement wait_for_internal_ip function to ensure dappmanager publishes INTERNAL_IP before proceeding * Add macOS server detection and adjust package selection for always-on Macs * Add patch for macOS non-server to use remote IPFS services in maindb.json * Enhance wait_for_internal_ip function to check for HOSTNAME alongside INTERNAL_IP and improve error messaging; add wait for maindb.json file existence in macOS non-server patch function * Remove macOS non-server patch for remote IPFS services from installation script * Remove default PROFILE_BRANCH assignment from installation script * Add support for minimal installation mode and enhance argument parsing in installer script * Increase wait time for VPN initialization in installer script * Add function to print VPN access credentials after core startup * Refactor Linux setup steps to conditionally execute based on MINIMAL mode * Add support for Notifications and Premium packages in installation scripts (#696) * Add local profile path argument to DAppNode installation script * Add support for macOS in VPN access credential retrieval * Add support for custom package selection in installation script * Add interactive setup wizard to installation script * Add conditional output for VPN credentials based on selected packages * Remove interactive mode support from installation script * Add support for lite installation mode in the installation script * Refactor installation script by removing macOS-specific checks and unused functions * Improve Docker prerequisite checks in installation script * Remove outdated comment regarding patch_compose_paths function in installation script --------- Co-authored-by: Marc Font <36164126+Marketen@users.noreply.github.com> --- .dappnode_profile | 2 + .github/workflows/release.yml | 17 +- .github/workflows/test.yml | 4 +- scripts/dappnode_install.sh | 1084 ++++++++++++++++++++++++++------- scripts/dappnode_uninstall.sh | 111 +++- 5 files changed, 989 insertions(+), 229 deletions(-) diff --git a/.dappnode_profile b/.dappnode_profile index 538e868f..ece7e1bd 100755 --- a/.dappnode_profile +++ b/.dappnode_profile @@ -14,6 +14,8 @@ export DAPPMANAGER_VERSION="${DAPPMANAGER_VERSION:-0.2.99}" export WIFI_VERSION="${WIFI_VERSION:-0.2.9}" export WIREGUARD_VERSION="${WIREGUARD_VERSION:-0.1.3}" export HTTPS_VERSION="${HTTPS:-0.2.2}" +export NOTIFICATIONS_VERSION="/ipfs/QmQubxH4WgqEFxvFntef4H2DmuU6mxBRS6XeuShc3owNi9" +export PREMIUM_VERSION="/ipfs/QmXDddoa56HkrvtkGsa3mozpsn9SzQZtoVBWgagcW6SsHy" export DAPPNODE_DIR="/usr/src/dappnode" export DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94223b52..ad7c934e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,12 @@ on: vpn: description: "Version of the OpenVPN Package. Only numbers" required: true + notifications: + description: "IPFS hash of the Notifications Package. Must start with /ipfs/" + required: true + premium: + description: "IPFS hash of the Premium Package. Must start with /ipfs/" + required: true jobs: set-versions: @@ -39,13 +45,16 @@ jobs: wireguard: ${{ steps.set_outputs.outputs.wireguard }} https: ${{ steps.set_outputs.outputs.https }} vpn: ${{ steps.set_outputs.outputs.vpn }} + notifications: ${{ steps.set_outputs.outputs.notifications }} + premium: ${{ steps.set_outputs.outputs.premium }} core: ${{ steps.set_outputs.outputs.core }} steps: - name: Check versions regex run: | [[ "${{ github.event.inputs.bind }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.ipfs }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.dappmanager }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && \ [[ "${{ github.event.inputs.wifi }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.wireguard }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.https }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && \ - [[ "${{ github.event.inputs.vpn }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.core }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "versions introduced in wrong format"; exit 1; } + [[ "${{ github.event.inputs.vpn }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "${{ github.event.inputs.core }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && \ + [[ "${{ github.event.inputs.notifications }}" =~ ^/ipfs/.+$ ]] && [[ "${{ github.event.inputs.premium }}" =~ ^/ipfs/.+$ ]] || { echo "versions introduced in wrong format"; exit 1; } - name: Checkout uses: actions/checkout@v4 - name: Set new versions @@ -56,7 +65,9 @@ jobs: sed -i -e "/DAPPMANAGER_VERSION/s/[0-9]*\.[0-9]*\.[0-9]*/"${{ github.event.inputs.dappmanager }}"/" .dappnode_profile sed -i -e "/WIFI_VERSION/s/[0-9]*\.[0-9]*\.[0-9]*/"${{ github.event.inputs.wifi }}"/" .dappnode_profile sed -i -e "/WIREGUARD_VERSION/s/[0-9]*\.[0-9]*\.[0-9]*/"${{ github.event.inputs.wireguard }}"/" .dappnode_profile - sed -i -e "/HTTPS_VERSION/s/[0-9]*\.[0-9]*\.[0-9]*/"${{ github.event.inputs.https }}"/" .dappnode_profile + sed -i -e "/HTTPS_VERSION/s/[0-9]*\.[0-9]*\.[0-9]*/${{ github.event.inputs.https }}/" .dappnode_profile + sed -i -e "s|^export NOTIFICATIONS_VERSION=.*|export NOTIFICATIONS_VERSION=\"${{ github.event.inputs.notifications }}\"|" .dappnode_profile + sed -i -e "s|^export PREMIUM_VERSION=.*|export PREMIUM_VERSION=\"${{ github.event.inputs.premium }}\"|" .dappnode_profile cat .dappnode_profile - name: Create dappnode_profile.sh run: cp .dappnode_profile dappnode_profile.sh @@ -76,6 +87,8 @@ jobs: echo "wireguard=${{ github.event.inputs.wireguard }}" >> $GITHUB_OUTPUT echo "https=${{ github.event.inputs.https }}" >> $GITHUB_OUTPUT echo "vpn=${{ github.event.inputs.vpn }}" >> $GITHUB_OUTPUT + echo "notifications=${{ github.event.inputs.notifications }}" >> $GITHUB_OUTPUT + echo "premium=${{ github.event.inputs.premium }}" >> $GITHUB_OUTPUT build-debian-attended: name: Build Debian attended ISO diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7c85e1b..deb5465a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: sudo /bin/bash ./scripts/dappnode_install_pre.sh UPDATE - name: Install DAppNode run: | - sudo /bin/bash ./scripts/dappnode_install.sh + sudo /bin/bash ./scripts/dappnode_install.sh --local-profile-path "$PWD/.dappnode_profile" - name: Show installation logs run: | cat /usr/src/dappnode/logs/install.log @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # Create Debian ISO - name: create Debian ISO diff --git a/scripts/dappnode_install.sh b/scripts/dappnode_install.sh index fc58ff17..0f6e4ab0 100755 --- a/scripts/dappnode_install.sh +++ b/scripts/dappnode_install.sh @@ -1,69 +1,540 @@ #!/bin/bash +# This installer is written for bash. It's safe to *run it from zsh* (it will execute via bash +# thanks to the shebang), but users sometimes invoke it as `zsh ./script.sh` or `source ./script.sh`. +# - If sourced, bail out (sourcing would pollute the current shell and can break it). +# - If invoked by a non-bash shell, re-exec with bash before hitting bash-specific builtins. +if (return 0 2>/dev/null); then + echo "This script must be executed, not sourced. Run: bash $0" + return 1 +fi + +if [ -z "${BASH_VERSION:-}" ]; then + exec /usr/bin/env bash "$0" "$@" +fi + +set -Eeuo pipefail + +# Optional env inputs (avoid unbound-variable errors under `set -u`) +: "${UPDATE:=false}" +: "${STATIC_IP:=}" +: "${LOCAL_PROFILE_PATH:=}" +: "${MINIMAL:=false}" +: "${LITE:=false}" +: "${PACKAGES:=}" + +# Enable alias expansion in non-interactive bash scripts. +# Required so commands like `dappnode_wireguard` (defined as aliases in `.dappnode_profile`) work. +shopt -s expand_aliases + +# Ensure array is always defined (avoid `set -u` edge cases) +DNCORE_COMPOSE_ARGS=() + +############################## +# Logging / Errors # +############################## + +log() { + # LOGFILE is created after dir bootstrap; until then we just print to stdout. + if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then + printf '%s\n' "$*" | tee -a "$LOGFILE" + else + printf '%s\n' "$*" + fi +} + +warn() { + log "[WARN] $*" +} + +die() { + log "[ERROR] $*" + exit 1 +} + +usage() { + cat <<'EOF' +Usage: dappnode_install.sh [options] + +Options: + --update Clean existing downloaded artifacts before installing (equivalent: UPDATE=true) + --static-ip Set a static IP (equivalent: STATIC_IP=...) + --local-profile-path Use a local .dappnode_profile instead of downloading (equivalent: LOCAL_PROFILE_PATH=...) + --ipfs-endpoint Override IPFS gateway endpoint (equivalent: IPFS_ENDPOINT=...) + --profile-url Override profile download URL (equivalent: PROFILE_URL=...) + --minimal Install only BIND DAPPMANAGER NOTIFICATIONS PREMIUM (equivalent: MINIMAL=true) + --lite Install reduced package set: BIND VPN WIREGUARD DAPPMANAGER NOTIFICATIONS PREMIUM (equivalent: LITE=true) + --packages Override package selection (comma or space separated), e.g. BIND,IPFS,VPN + -h, --help Show this help + +Environment variables (also supported): + UPDATE, STATIC_IP, LOCAL_PROFILE_PATH, IPFS_ENDPOINT, PROFILE_URL, MINIMAL, LITE, PACKAGES +EOF +} + +parse_args() { + while [[ $# -gt 0 ]]; do + case "$1" in + --update) + UPDATE=true + shift + ;; + --static-ip) + [[ $# -ge 2 ]] || die "--static-ip requires an IPv4 argument" + STATIC_IP="$2" + shift 2 + ;; + --local-profile-path) + [[ $# -ge 2 ]] || die "--local-profile-path requires a path argument" + LOCAL_PROFILE_PATH="$2" + shift 2 + ;; + --ipfs-endpoint) + [[ $# -ge 2 ]] || die "--ipfs-endpoint requires a URL argument" + IPFS_ENDPOINT="$2" + shift 2 + ;; + --profile-url) + [[ $# -ge 2 ]] || die "--profile-url requires a URL argument" + PROFILE_URL="$2" + shift 2 + ;; + --minimal) + MINIMAL=true + shift + ;; + --lite) + LITE=true + shift + ;; + --packages) + [[ $# -ge 2 ]] || die "--packages requires a package list argument" + PACKAGES="$2" + shift 2 + ;; + --packages=*) + PACKAGES="${1#*=}" + shift + ;; + -h|--help) + usage + exit 0 + ;; + --) + shift + break + ;; + *) + die "Unknown option: $1 (use --help)" + ;; + esac + done +} + +validate_install_mode() { + if [[ "${MINIMAL}" == "true" && "${LITE}" == "true" ]]; then + die "--minimal and --lite are mutually exclusive" + fi +} + +require_cmd() { + local cmd="$1" + command -v "$cmd" >/dev/null 2>&1 || die "Missing required command: $cmd" +} + +require_downloader() { + if command -v curl >/dev/null 2>&1; then + return 0 + fi + if command -v wget >/dev/null 2>&1; then + return 0 + fi + die "Missing required downloader: install curl or wget" +} + +check_prereqs() { + if ! command -v docker >/dev/null 2>&1; then + die "Docker is not installed. Install Docker first, then re-run this installer." + fi + + # Docker CLI may exist while the daemon is stopped/unreachable. + if ! docker info >/dev/null 2>&1; then + die "Docker is installed but not running (or not reachable). Start Docker and try again." + fi + + require_downloader + + # Ensure compose is available (Docker Desktop / modern docker engine) + if ! docker compose version >/dev/null 2>&1; then + die "Docker Compose not available (expected: 'docker compose'). Update Docker or install the compose plugin." + fi +} + +# Wait until dappmanager publishes INTERNAL_IP via its local HTTP endpoint. +# Runs the curl inside the provided container and exits with error on timeout. +# Usage: wait_for_internal_ip [timeout_seconds] [initial_sleep_seconds] +wait_for_internal_ip() { + local container_name="$1" + local timeout_seconds="${2:-120}" + local initial_sleep_seconds="${3:-10}" + local internal_ip_url="http://127.0.0.1/global-envs/INTERNAL_IP" + local hostname_url="http://127.0.0.1/global-envs/HOSTNAME" + + echo "Waiting for dappmanager to publish INTERNAL_IP and HOSTNAME..." + sleep "$initial_sleep_seconds" + + local start_seconds internal_http_code internal_value internal_result + local hostname_http_code hostname_value hostname_result + start_seconds=$SECONDS + internal_http_code="" + internal_value="" + hostname_http_code="" + hostname_value="" + + while true; do + if (( SECONDS - start_seconds >= timeout_seconds )); then + die "Timed out after ${timeout_seconds}s waiting for INTERNAL_IP and HOSTNAME from dappmanager (expected HTTP 200 with non-empty values). Last seen: INTERNAL_IP code=${internal_http_code:-?} value=${internal_value:-}; HOSTNAME code=${hostname_http_code:-?} value=${hostname_value:-}" + fi + + # Must be executed inside the dappmanager container. + # Return format is: + # \n + # Parse in bash (not inside container sh) to avoid shell portability issues. + + internal_result="$( + docker exec -i "$container_name" sh -lc "curl -sS -w '\n%{http_code}' '$internal_ip_url' 2>/dev/null || true" 2>/dev/null || true + )" + internal_http_code="$(printf '%s\n' "$internal_result" | tail -n 1 | tr -d '\r')" + internal_value="$(printf '%s\n' "$internal_result" | head -n 1 | tr -d '\r' | xargs)" + + hostname_result="$( + docker exec -i "$container_name" sh -lc "curl -sS -w '\n%{http_code}' '$hostname_url' 2>/dev/null || true" 2>/dev/null || true + )" + hostname_http_code="$(printf '%s\n' "$hostname_result" | tail -n 1 | tr -d '\r')" + hostname_value="$(printf '%s\n' "$hostname_result" | head -n 1 | tr -d '\r' | xargs)" + + if [[ "$internal_http_code" == "200" && -n "$internal_value" && "$internal_value" != "null" && "$hostname_http_code" == "200" && -n "$hostname_value" && "$hostname_value" != "null" ]]; then + sleep 2 # Extra buffer to ensure values are fully propagated before we proceed + echo "INTERNAL_IP is ready: $internal_value" + echo "HOSTNAME is ready: $hostname_value" + return 0 + fi + + echo "INTERNAL_IP/HOSTNAME not ready yet (INTERNAL_IP code=${internal_http_code:-?}, HOSTNAME code=${hostname_http_code:-?}). Retrying..." + sleep 2 + done +} + +# Print VPN access credentials (Wireguard + OpenVPN) after core has started. +# Works on both Linux and macOS as long as the relevant containers are running. +print_vpn_access_credentials() { + local localhost_flag=() + local has_wireguard=false + local has_vpn=false + local pkg + + if $IS_MACOS; then + localhost_flag=(--localhost) + fi + + for pkg in "${PKGS[@]}"; do + if [[ "$pkg" == "WIREGUARD" ]]; then + has_wireguard=true + elif [[ "$pkg" == "VPN" ]]; then + has_vpn=true + fi + done + + if [[ "$has_wireguard" != "true" && "$has_vpn" != "true" ]]; then + echo "" + echo "No VPN package selected (VPN/WIREGUARD). Skipping credentials output." + return 0 + fi + + echo "" + echo "Waiting for VPN initialization..." + wait_for_internal_ip "DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 20 + + echo "" + echo "##############################################" + echo "# DAppNode VPN Access Credentials #" + echo "##############################################" + echo "" + echo "Your DAppNode is ready! Connect using your preferred VPN client." + echo "Choose either Wireguard (recommended) or OpenVPN and import the" + echo "credentials below into your VPN app to access your DAppNode." + echo "" + + if [[ "$has_wireguard" == "true" ]]; then + echo "--- Wireguard ---" + docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials "${localhost_flag[@]}" 2>&1 || \ + echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard${localhost_flag:+ ${localhost_flag[*]}}" + fi + + if [[ "$has_wireguard" == "true" && "$has_vpn" == "true" ]]; then + echo "" + fi + + if [[ "$has_vpn" == "true" ]]; then + echo "--- OpenVPN ---" + docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get dappnode_admin "${localhost_flag[@]}" 2>&1 || \ + echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin${localhost_flag:+ ${localhost_flag[*]}}" + fi + + echo "" + echo "Import the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode" +} + +# Build docker compose "-f " args from downloaded compose files. +# This avoids depending on alias expansion or profile-generated strings. +build_dncore_compose_args() { + DNCORE_COMPOSE_ARGS=() + local file + while IFS= read -r file; do + [[ -n "$file" ]] || continue + DNCORE_COMPOSE_ARGS+=( -f "$file" ) + done < <(find "${DAPPNODE_CORE_DIR}" -name 'docker-compose-*.yml' -print 2>/dev/null | sort) +} + +################## +# OS DETECTION # +################## +OS_TYPE="$(uname -s)" +IS_MACOS=false +IS_LINUX=false +if [[ "$OS_TYPE" == "Darwin" ]]; then + IS_MACOS=true +elif [[ "$OS_TYPE" == "Linux" ]]; then + IS_LINUX=true +else + die "Unsupported operating system: $OS_TYPE" +fi + ############# # VARIABLES # ############# -# Dirs -DAPPNODE_DIR="/usr/src/dappnode" +# Dirs - macOS uses $HOME/dappnode, Linux uses /usr/src/dappnode +if $IS_MACOS; then + DAPPNODE_DIR="$HOME/dappnode" +else + DAPPNODE_DIR="/usr/src/dappnode" +fi DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE" LOGS_DIR="$DAPPNODE_DIR/logs" # Files CONTENT_HASH_FILE="${DAPPNODE_CORE_DIR}/packages-content-hash.csv" LOGFILE="${LOGS_DIR}/dappnode_install.log" -MOTD_FILE="/etc/motd" -UPDATE_MOTD_DIR="/etc/update-motd.d" DAPPNODE_PROFILE="${DAPPNODE_CORE_DIR}/.dappnode_profile" +# Linux-only paths +if $IS_LINUX; then + MOTD_FILE="/etc/motd" + UPDATE_MOTD_DIR="/etc/update-motd.d" +fi # Get URLs -PROFILE_BRANCH=${PROFILE_BRANCH:-"master"} -IPFS_ENDPOINT=${IPFS_ENDPOINT:-"http://ipfs.io"} +IPFS_ENDPOINT=${IPFS_ENDPOINT:-"https://ipfs-gateway-dev.dappnode.net"} # PROFILE_URL env is used to fetch the core packages versions that will be used to build the release in script install method PROFILE_URL=${PROFILE_URL:-"https://github.com/dappnode/DAppNode/releases/latest/download/dappnode_profile.sh"} DAPPNODE_ACCESS_CREDENTIALS="${DAPPNODE_DIR}/scripts/dappnode_access_credentials.sh" DAPPNODE_ACCESS_CREDENTIALS_URL="https://github.com/dappnode/DAppNode/releases/latest/download/dappnode_access_credentials.sh" -WGET="wget -q --show-progress --progress=bar:force" -SWGET="wget -q -O-" # Other -CONTENT_HASH_PKGS=(geth besu nethermind erigon prysm teku lighthouse nimbus lodestar) -ARCH=$(dpkg --print-architecture) -WELCOME_MESSAGE="\nChoose a way to connect to your DAppNode, then go to \e[1mhttp://my.dappnode\e[0m\n\n\e[1m- Wifi\e[0m\t\tScan and connect to DAppNodeWIFI. Get wifi credentials with \e[32mdappnode_wifi\e[0m\n\n\e[1m- Local Proxy\e[0m\tConnect to the same router as your DAppNode. Then go to \e[1mhttp://dappnode.local\e[0m\n\n\e[1m- Wireguard\e[0m\tDownload Wireguard app on your device. Get your dappnode wireguard credentials with \e[32mdappnode_wireguard\e[0m\n\n\e[1m- Open VPN\e[0m\tDownload OPen VPN app on your device. Get your openVPN creds with \e[32mdappnode_openvpn\e[0m\n\n\nTo see a full list of commands available execute \e[32mdappnode_help\e[0m\n" - -# Clean if update -if [ "$UPDATE" = true ]; then - echo "Cleaning for update..." - rm -rf $LOGFILE - rm -rf ${DAPPNODE_CORE_DIR}/docker-compose-*.yml - rm -rf ${DAPPNODE_CORE_DIR}/dappnode_package-*.json - rm -rf ${DAPPNODE_CORE_DIR}/*.tar.xz - rm -rf ${DAPPNODE_CORE_DIR}/*.txz - rm -rf ${DAPPNODE_CORE_DIR}/.dappnode_profile - rm -rf ${CONTENT_HASH_FILE} + +# Architecture detection (cross-platform) +if $IS_MACOS; then + ARCH="$(uname -m)" + [[ "$ARCH" == "x86_64" ]] && ARCH="amd64" + # arm64 is already correct for Apple Silicon +else + ARCH="$(dpkg --print-architecture)" fi -# Create necessary directories -mkdir -p $DAPPNODE_DIR -mkdir -p $DAPPNODE_CORE_DIR -mkdir -p "${DAPPNODE_DIR}/scripts" -mkdir -p "${DAPPNODE_CORE_DIR}/scripts" -mkdir -p "${DAPPNODE_DIR}/config" -mkdir -p $LOGS_DIR - -# TEMPORARY: think a way to integrate flags instead of use files to detect installation type -is_iso_install() { - # Check old and new location of iso_install.log - if [ -f "${DAPPNODE_DIR}/iso_install.log" ] || [ -f "${DAPPNODE_DIR}/logs/iso_install.log" ]; then - IS_ISO_INSTALL=true +############################## +# Cross-platform Helpers # +############################## + +# Download a file: download_file +download_file() { + local dest="$1" + local url="$2" + log "Downloading from $url to $dest" + mkdir -p "$(dirname "$dest")" + if command -v curl >/dev/null 2>&1; then + curl -fsSL -o "$dest" "$url" + return + fi + wget -q --show-progress --progress=bar:force -O "$dest" "$url" +} + +# Download content to stdout: download_stdout +download_stdout() { + local url="$1" + if command -v curl >/dev/null 2>&1; then + curl -fsSL "$url" + return + fi + wget -q -O- "$url" +} + +# Normalize IPFS refs and (if needed) infer the missing : from dappnode_package.json +# Accepts: +# - /ipfs/: +# - /ipfs/ (version inferred) +# - ipfs/[:] (leading slash normalized) +normalize_ipfs_version_ref() { + local raw_ref="$1" + local comp="$2" + local ref="$raw_ref" + + if [[ "$ref" == ipfs/* ]]; then + ref="/$ref" + fi + + # If it already has :, we're done + if [[ "$ref" == /ipfs/*:* ]]; then + echo "$ref" + return 0 + fi + + # If it's an IPFS ref without a :, infer it from the manifest in the CID + if [[ "$ref" == /ipfs/* ]]; then + local cid_path="$ref" + local manifest_url="${IPFS_ENDPOINT%/}${cid_path}/dappnode_package.json" + local manifest + manifest="$(download_stdout "$manifest_url" 2>/dev/null || true)" + if [[ -z "$manifest" ]]; then + echo "[ERROR] Could not fetch IPFS manifest for ${comp} from: $manifest_url" 1>&2 + echo "[ERROR] Provide ${comp}_VERSION as /ipfs/: (example: /ipfs/Qm...:0.2.11)" 1>&2 + return 1 + fi + + local inferred_version + inferred_version="$( + echo "$manifest" | + tr -d '\r' | + grep -m1 '"version"' | + sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^\"]+)".*/\1/' + )" + + if [[ -z "$inferred_version" || "$inferred_version" == "$manifest" ]]; then + echo "[ERROR] Could not infer version for ${comp} from IPFS manifest: $manifest_url" 1>&2 + echo "[ERROR] Provide ${comp}_VERSION as /ipfs/:" 1>&2 + return 1 + fi + + echo "${cid_path}:${inferred_version}" + return 0 + fi + + # Not an IPFS ref; return as-is + echo "$raw_ref" +} + +# Cross-platform in-place sed (macOS requires '' after -i) +sed_inplace() { + if $IS_MACOS; then + sed -i '' "$@" else - IS_ISO_INSTALL=false + sed -i "$@" fi } +############################## +# Compose Patching Helpers # +############################## + +# Remove journald logging from compose files (not supported on macOS Docker Desktop) +remove_logging_section() { + local file="$1" + sed_inplace '/logging/d;/journald/d' "$file" +} + +# Replace Linux paths with macOS paths in compose files +patch_compose_paths() { + local file="$1" + sed_inplace "s|/usr/src/dappnode|${DAPPNODE_DIR}|g" "$file" +} + +# Patch dappmanager compose for macOS: inject env vars the container needs +# to know the host core-dir path and to skip host-only operations, +# and fix the DNCORE volume mount to use the macOS host path. +patch_dappmanager_compose_for_macos() { + local file="$1" + + # Replace the host side of the DNCORE volume mount with the actual DAPPNODE_CORE_DIR value + # e.g. /usr/src/dappnode/DNCORE/:/usr/src/app/DNCORE/ -> $HOME/dappnode/DNCORE/:/usr/src/app/DNCORE/ + sed_inplace "s|[^[:space:]]*:/usr/src/app/DNCORE/|${DAPPNODE_CORE_DIR}/:/usr/src/app/DNCORE/|" "$file" + + local envs_to_add=() + + # DAPPNODE_CORE_DIR: lets the container know the host's DNCORE path + if ! grep -q "DAPPNODE_CORE_DIR" "$file"; then + envs_to_add+=(" - DAPPNODE_CORE_DIR=${DAPPNODE_CORE_DIR}") + fi + + # DISABLE_HOST_SCRIPTS: tells the container to skip host-only scripts + if ! grep -q "DISABLE_HOST_SCRIPTS" "$file"; then + envs_to_add+=(" - DISABLE_HOST_SCRIPTS=${DISABLE_HOST_SCRIPTS}") + fi + + [[ ${#envs_to_add[@]} -gt 0 ]] || return 0 + + local tmp="${file}.tmp" + local insert_file="${file}.envinsert" + + # macOS ships BSD awk, which can error with "newline in string" if a -v argument contains + # literal newlines. Write the insertion block to a temp file and have awk read it. + printf '%s\n' "${envs_to_add[@]}" >"$insert_file" + + awk -v insfile="$insert_file" ' + /^[[:space:]]*environment:[[:space:]]*$/ { + print + while ((getline line < insfile) > 0) print line + close(insfile) + next + } + { print } + ' "$file" >"$tmp" && mv "$tmp" "$file" + + rm -f "$insert_file" || true +} + +bootstrap_filesystem() { + # Clean if update + if [[ "${UPDATE}" == "true" ]]; then + echo "Cleaning for update..." + rm -f "${LOGFILE}" || true + rm -f "${DAPPNODE_CORE_DIR}"/docker-compose-*.yml || true + rm -f "${DAPPNODE_CORE_DIR}"/dappnode_package-*.json || true + rm -f "${DAPPNODE_CORE_DIR}"/*.tar.xz || true + rm -f "${DAPPNODE_CORE_DIR}"/*.txz || true + rm -f "${DAPPNODE_CORE_DIR}/.dappnode_profile" || true + rm -f "${CONTENT_HASH_FILE}" || true + fi + + # Create necessary directories + mkdir -p "${DAPPNODE_DIR}" + mkdir -p "${DAPPNODE_CORE_DIR}" + mkdir -p "${DAPPNODE_DIR}/scripts" + mkdir -p "${DAPPNODE_CORE_DIR}/scripts" + mkdir -p "${DAPPNODE_DIR}/config" + mkdir -p "${LOGS_DIR}" + + # Ensure the log file path exists before first use by helpers. + touch "${LOGFILE}" || true +} + # Check if port 80 is in use (necessary for HTTPS) # Returns IS_PORT_USED=true only if port 80 or 443 is used by something OTHER than our HTTPS container is_port_used() { # Check if port 80 or 443 is in use at all local port80_used port443_used - lsof -i -P -n | grep ":80 (LISTEN)" &>/dev/null && port80_used=true || port80_used=false - lsof -i -P -n | grep ":443 (LISTEN)" &>/dev/null && port443_used=true || port443_used=false + if command -v lsof >/dev/null 2>&1; then + lsof -i -P -n | grep ":80 (LISTEN)" &>/dev/null && port80_used=true || port80_used=false + lsof -i -P -n | grep ":443 (LISTEN)" &>/dev/null && port443_used=true || port443_used=false + else + warn "lsof not found; assuming ports 80/443 are in use (HTTPS will be skipped)" + IS_PORT_USED=true + return + fi if [ "$port80_used" = false ] && [ "$port443_used" = false ]; then IS_PORT_USED=false @@ -82,98 +553,221 @@ is_port_used() { # Determine packages to be installed determine_packages() { - is_iso_install - is_port_used - if [ "$IS_ISO_INSTALL" == "false" ]; then - if [ "$IS_PORT_USED" == "true" ]; then - PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI) - else - PKGS=(HTTPS BIND IPFS WIREGUARD DAPPMANAGER WIFI) + # Explicit package list override from flag/env always has top priority. + # It supersedes MINIMAL/LITE and any OS/port-based package determination. + if [[ -n "${PACKAGES//[[:space:],]/}" ]]; then + local raw token normalized + local custom_pkgs=() + + raw="${PACKAGES//,/ }" + for token in $raw; do + normalized="$(echo "$token" | tr '[:lower:]' '[:upper:]')" + case "$normalized" in + HTTPS|BIND|IPFS|VPN|WIREGUARD|DAPPMANAGER|WIFI|NOTIFICATIONS|PREMIUM) + ;; + *) + die "Unknown package in --packages/PACKAGES: '$token'. Allowed: HTTPS,BIND,IPFS,VPN,WIREGUARD,DAPPMANAGER,WIFI,NOTIFICATIONS,PREMIUM" + ;; + esac + + local exists=false + local pkg + for pkg in "${custom_pkgs[@]}"; do + if [[ "$pkg" == "$normalized" ]]; then + exists=true + break + fi + done + + if [[ "$exists" == "false" ]]; then + custom_pkgs+=("$normalized") + fi + done + + [[ ${#custom_pkgs[@]} -gt 0 ]] || die "--packages/PACKAGES was provided but no valid packages were found" + + # DAPPMANAGER is required for a functional install; ensure it's present on explicit overrides. + local has_dappmanager=false + local pkg + for pkg in "${custom_pkgs[@]}"; do + if [[ "$pkg" == "DAPPMANAGER" ]]; then + has_dappmanager=true + break + fi + done + if [[ "$has_dappmanager" == "false" ]]; then + custom_pkgs+=("DAPPMANAGER") + log "--packages/PACKAGES did not include DAPPMANAGER; appending it automatically" fi - else - if [ "$IS_PORT_USED" == "true" ]; then - PKGS=(BIND IPFS WIREGUARD DAPPMANAGER WIFI) - else - PKGS=(HTTPS BIND IPFS WIREGUARD DAPPMANAGER WIFI) + + if [[ "${MINIMAL}" == "true" || "${LITE}" == "true" ]]; then + log "Custom packages provided; overriding --minimal/--lite and MINIMAL/LITE" fi + MINIMAL=false + LITE=false + PKGS=("${custom_pkgs[@]}") + + log "Packages override enabled via --packages/PACKAGES" + log "Packages to be installed: ${PKGS[*]}" + log "PKGS: ${PKGS[*]}" + for comp in "${PKGS[@]}"; do + local ver_var + ver_var="${comp}_VERSION" + log "$ver_var = ${!ver_var-}" + done + return 0 fi - echo -e "\e[32mPackages to be installed: ${PKGS[*]}\e[0m" 2>&1 | tee -a $LOGFILE -} -function valid_ip() { - local ip=$1 - local stat=1 + # Global override: new minimal install, regardless of OS. + if [[ "${MINIMAL}" == "true" ]]; then + PKGS=(BIND DAPPMANAGER NOTIFICATIONS PREMIUM) + log "Minimal mode enabled; overriding packages" + log "Packages to be installed: ${PKGS[*]}" + log "PKGS: ${PKGS[*]}" + for comp in "${PKGS[@]}"; do + local ver_var + ver_var="${comp}_VERSION" + log "$ver_var = ${!ver_var-}" + done + return 0 + fi - if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - OIFS=$IFS - IFS='.' - ip=("$ip") - IFS=$OIFS - [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && - ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] - stat=$? + # Global override: lite install (former minimal behavior), regardless of OS. + if [[ "${LITE}" == "true" ]]; then + PKGS=(BIND VPN WIREGUARD DAPPMANAGER NOTIFICATIONS PREMIUM) + log "Lite mode enabled; overriding packages" + log "Packages to be installed: ${PKGS[*]}" + log "PKGS: ${PKGS[*]}" + for comp in "${PKGS[@]}"; do + local ver_var + ver_var="${comp}_VERSION" + log "$ver_var = ${!ver_var-}" + done + return 0 fi - return $stat + + # Default mode (no --packages/--minimal/--lite): install full package set. + # HTTPS is included only when ports 80/443 are available. + is_port_used + if [ "$IS_PORT_USED" == "true" ]; then + PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM) + else + PKGS=(HTTPS BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM) + fi + + log "Packages to be installed: ${PKGS[*]}" + + # Debug: print all PKGS and their version variables + log "PKGS: ${PKGS[*]}" + for comp in "${PKGS[@]}"; do + local ver_var + ver_var="${comp}_VERSION" + log "$ver_var = ${!ver_var-}" + done } -if [[ -n "$STATIC_IP" ]]; then +valid_ip() { + local ip="$1" + if [[ ! "$ip" =~ ^[0-9]{1,3}(\.[0-9]{1,3}){3}$ ]]; then + return 1 + fi + + local IFS='.' + # shellcheck disable=SC2206 + local octets=( $ip ) + [[ ${#octets[@]} -eq 4 ]] || return 1 + [[ ${octets[0]} -le 255 && ${octets[1]} -le 255 && ${octets[2]} -le 255 && ${octets[3]} -le 255 ]] +} + +configure_static_ip() { + if [[ -z "${STATIC_IP}" ]]; then + return 0 + fi + if valid_ip "$STATIC_IP"; then - echo "$STATIC_IP" >${DAPPNODE_DIR}/config/static_ip + echo "$STATIC_IP" >"${DAPPNODE_DIR}/config/static_ip" else - echo "The static IP provided: ${STATIC_IP} is not valid." - exit 1 + die "The static IP provided (${STATIC_IP}) is not valid." fi -fi +} -# Loads profile, if not exists it means it is script install so the versions will be fetched from the latest profile -[ -f $DAPPNODE_PROFILE ] || ${WGET} -O ${DAPPNODE_PROFILE} ${PROFILE_URL} -# shellcheck disable=SC1090 -source "${DAPPNODE_PROFILE}" - -# The indirect variable expansion used in ${!ver##*:} allows us to use versions like 'dev:development' -# If such variable with 'dev:'' suffix is used, then the component is built from specified branch or commit. -# you can also specify an IPFS version like /ipfs/QmWg8P2b9JKQ8thAVz49J8SbJbCoi2MwkHnUqMtpzDTtxR:0.2.7, it's important -# to include the exact version also in the IPFS hash format since it's needed to be able to download it -determine_packages -for comp in "${PKGS[@]}"; do - ver="${comp}_VERSION" - DOWNLOAD_URL="https://github.com/dappnode/DNP_${comp}/releases/download/v${!ver}" - if [[ ${!ver} == /ipfs/* ]]; then - DOWNLOAD_URL="${IPFS_ENDPOINT}/api/v0/cat?arg=${!ver%:*}" - fi - eval "${comp}_URL=\"${DOWNLOAD_URL}/${comp,,}.dnp.dappnode.eth_${!ver##*:}_linux-${ARCH}.txz\"" - eval "${comp}_YML=\"${DOWNLOAD_URL}/docker-compose.yml\"" - eval "${comp}_MANIFEST=\"${DOWNLOAD_URL}/dappnode_package.json\"" - eval "${comp}_YML_FILE=\"${DAPPNODE_CORE_DIR}/docker-compose-${comp,,}.yml\"" - eval "${comp}_FILE=\"${DAPPNODE_CORE_DIR}/${comp,,}.dnp.dappnode.eth_${!ver##*:}_linux-${ARCH}.txz\"" - eval "${comp}_MANIFEST_FILE=\"${DAPPNODE_CORE_DIR}/dappnode_package-${comp,,}.json\"" -done +ensure_profile_loaded() { + # If LOCAL_PROFILE_PATH is set, use it as the profile source instead of downloading + if [[ -n "${LOCAL_PROFILE_PATH}" ]]; then + log "Using local profile: ${LOCAL_PROFILE_PATH}" + cp "$LOCAL_PROFILE_PATH" "$DAPPNODE_PROFILE" + elif [[ ! -f "$DAPPNODE_PROFILE" ]]; then + download_file "${DAPPNODE_PROFILE}" "${PROFILE_URL}" + fi + + # shellcheck disable=SC1090 + source "${DAPPNODE_PROFILE}" +} + +resolve_packages() { + # The indirect variable expansion used in ${!ver##*:} allows us to use versions like 'dev:development' + # If such variable with 'dev:'' suffix is used, then the component is built from specified branch or commit. + # you can also specify an IPFS version like /ipfs/: (the exact version is required). + determine_packages + for comp in "${PKGS[@]}"; do + ver="${comp}_VERSION" + log "Processing $comp: ${!ver-}" + + raw_version_ref="${!ver-}" + if [[ "$raw_version_ref" == /ipfs/* || "$raw_version_ref" == ipfs/* ]]; then + resolved_ref="$(normalize_ipfs_version_ref "$raw_version_ref" "$comp")" || exit 1 + printf -v "${comp}_VERSION" '%s' "$resolved_ref" + raw_version_ref="$resolved_ref" + log "Using IPFS for ${comp}: ${raw_version_ref%:*} (version ${raw_version_ref##*:})" + DOWNLOAD_URL="${IPFS_ENDPOINT%/}${raw_version_ref%:*}" + version_for_filenames="${raw_version_ref##*:}" + else + version_for_filenames="${raw_version_ref##*:}" + DOWNLOAD_URL="https://github.com/dappnode/DNP_${comp}/releases/download/v${version_for_filenames}" + fi + comp_lower="$(echo "$comp" | tr '[:upper:]' '[:lower:]')" + printf -v "${comp}_URL" '%s' "${DOWNLOAD_URL}/${comp_lower}.dnp.dappnode.eth_${version_for_filenames}_linux-${ARCH}.txz" + printf -v "${comp}_YML" '%s' "${DOWNLOAD_URL}/docker-compose.yml" + printf -v "${comp}_MANIFEST" '%s' "${DOWNLOAD_URL}/dappnode_package.json" + printf -v "${comp}_YML_FILE" '%s' "${DAPPNODE_CORE_DIR}/docker-compose-${comp_lower}.yml" + printf -v "${comp}_FILE" '%s' "${DAPPNODE_CORE_DIR}/${comp_lower}.dnp.dappnode.eth_${version_for_filenames}_linux-${ARCH}.txz" + printf -v "${comp}_MANIFEST_FILE" '%s' "${DAPPNODE_CORE_DIR}/dappnode_package-${comp_lower}.json" + done +} dappnode_core_build() { for comp in "${PKGS[@]}"; do ver="${comp}_VERSION" if [[ ${!ver} == dev:* ]]; then + if $IS_MACOS; then + echo "Development builds (dev:*) are not supported on macOS." + exit 1 + fi echo "Cloning & building DNP_${comp}..." if ! dpkg -s git >/dev/null 2>&1; then apt-get install -y git fi - TMPDIR=$(mktemp -d) - pushd "$TMPDIR" || { + local tmpdir + tmpdir="$(mktemp -d)" + pushd "$tmpdir" >/dev/null || { echo "Error on pushd" exit 1 } git clone -b "${!ver##*:}" https://github.com/dappnode/DNP_"${comp}" # Change version in YAML to the custom one - DOCKER_VER=$(echo "${!ver##*:}" | sed 's/\//_/g') - sed -i "s~^\(\s*image\s*:\s*\).*~\1${comp,,}.dnp.dappnode.eth:${DOCKER_VER}~" DNP_"${comp}"/docker-compose.yml + local docker_ver comp_lower + docker_ver="$(echo "${!ver##*:}" | sed 's/\//_/g')" + comp_lower="$(echo "$comp" | tr '[:upper:]' '[:lower:]')" + sed_inplace "s~^\(\s*image\s*:\s*\).*~\1${comp_lower}.dnp.dappnode.eth:${docker_ver}~" "DNP_${comp}/docker-compose.yml" docker compose -f ./DNP_"${comp}"/docker-compose.yml build - cp ./DNP_"${comp}"/docker-compose.yml "${DAPPNODE_CORE_DIR}"/docker-compose-"${comp,,}".yml - cp ./DNP_"${comp}"/dappnode_package.json "${DAPPNODE_CORE_DIR}"/dappnode_package-"${comp,,}".json - rm -r ./DNP_"${comp}" - popd || { + cp "./DNP_${comp}/docker-compose.yml" "${DAPPNODE_CORE_DIR}/docker-compose-${comp_lower}.yml" + cp "./DNP_${comp}/dappnode_package.json" "${DAPPNODE_CORE_DIR}/dappnode_package-${comp_lower}.json" + rm -rf "./DNP_${comp}" + popd >/dev/null || { echo "Error on popd" exit 1 } + rm -rf "$tmpdir" fi done } @@ -182,15 +776,32 @@ dappnode_core_download() { for comp in "${PKGS[@]}"; do ver="${comp}_VERSION" if [[ ${!ver} != dev:* ]]; then - # Download DAppNode Core Images if it's needed + local file_var="${comp}_FILE" + local url_var="${comp}_URL" + local yml_file_var="${comp}_YML_FILE" + local yml_var="${comp}_YML" + local manifest_file_var="${comp}_MANIFEST_FILE" + local manifest_var="${comp}_MANIFEST" + + # Download DAppNode Core Images if needed echo "Downloading ${comp} tar..." - eval "[ -f \$${comp}_FILE ] || $WGET -O \$${comp}_FILE \$${comp}_URL || exit 1" - # Download DAppNode Core docker-compose yml files if it's needed + [ -f "${!file_var}" ] || download_file "${!file_var}" "${!url_var}" || exit 1 + # Download DAppNode Core docker-compose yml files if needed echo "Downloading ${comp} yml..." - eval "[ -f \$${comp}_YML_FILE ] || $WGET -O \$${comp}_YML_FILE \$${comp}_YML || exit 1" - # Download DAppNode Core manifest files if it's needed + [ -f "${!yml_file_var}" ] || download_file "${!yml_file_var}" "${!yml_var}" || exit 1 + # Download DAppNode Core manifest files if needed echo "Downloading ${comp} manifest..." - eval "[ -f \$${comp}_MANIFEST_FILE ] || $WGET -O \$${comp}_MANIFEST_FILE \$${comp}_MANIFEST || exit 1" + [ -f "${!manifest_file_var}" ] || download_file "${!manifest_file_var}" "${!manifest_var}" || exit 1 + + # macOS: patch compose files for Docker Desktop compatibility + if $IS_MACOS; then + remove_logging_section "${!yml_file_var}" + patch_compose_paths "${!yml_file_var}" + # Inject macOS-specific env vars into the dappmanager compose + if [[ "$comp" == "DAPPMANAGER" ]]; then + patch_dappmanager_compose_for_macos "${!yml_file_var}" + fi + fi fi done } @@ -199,13 +810,18 @@ dappnode_core_load() { for comp in "${PKGS[@]}"; do ver="${comp}_VERSION" if [[ ${!ver} != dev:* ]]; then - eval "[ ! -z \$(docker images -q ${comp,,}.dnp.dappnode.eth:${!ver##*:}) ] || docker load -i \$${comp}_FILE 2>&1 | tee -a \$LOGFILE" + local comp_lower image file_var + comp_lower="$(echo "$comp" | tr '[:upper:]' '[:lower:]')" + image="${comp_lower}.dnp.dappnode.eth:${!ver##*:}" + file_var="${comp}_FILE" + if [[ -z "$(docker images -q "$image" 2>/dev/null)" ]]; then + docker load -i "${!file_var}" 2>&1 | tee -a "$LOGFILE" + fi fi done } customMotd() { - generateMotdText if [ -d "${UPDATE_MOTD_DIR}" ]; then @@ -216,6 +832,8 @@ customMotd() { # Debian distros use /etc/motd plain text file generateMotdText() { + local welcome_message + # Check and create the MOTD file if it does not exist if [ ! -f "${MOTD_FILE}" ]; then touch "${MOTD_FILE}" @@ -229,11 +847,13 @@ generateMotdText() { |___/\__,_| .__/ .__/_||_\___/\__,_\___| |_| |_| EOF - echo -e "$WELCOME_MESSAGE" >>"${MOTD_FILE}" + welcome_message="\nChoose a way to connect to your DAppNode, then go to http://my.dappnode\n\n- Wifi\t\tScan and connect to DAppNodeWIFI. Get wifi credentials with dappnode_wifi\n\n- Local Proxy\tConnect to the same router as your DAppNode. Then go to http://dappnode.local\n\n- Wireguard\tDownload Wireguard app on your device. Get your dappnode wireguard credentials with dappnode_wireguard\n\n- Open VPN\tDownload Open VPN app on your device. Get your openVPN creds with dappnode_openvpn\n\n\nTo see a full list of commands available execute dappnode_help\n" + printf "%b" "$welcome_message" >>"${MOTD_FILE}" } # Ubuntu distros use /etc/update-motd.d/ to generate the motd modifyMotdGeneration() { + local disabled_motd_dir disabled_motd_dir="${UPDATE_MOTD_DIR}/disabled" mkdir -p "${disabled_motd_dir}" @@ -241,8 +861,9 @@ modifyMotdGeneration() { # Move all the files in /etc/update-motd.d/ to /etc/update-motd.d/disabled/ # Except for the files listed in "files_to_keep" files_to_keep="00-header 50-landscape-sysinfo 98-reboot-required" - for file in ${UPDATE_MOTD_DIR}/*; do - base_file=$(basename "${file}") + local file base_file + for file in "${UPDATE_MOTD_DIR}"/*; do + base_file="$(basename "${file}")" if [ -f "${file}" ] && ! echo "${files_to_keep}" | grep -qw "${base_file}"; then mv "${file}" "${disabled_motd_dir}/" fi @@ -255,81 +876,105 @@ addSwap() { # if not then create it if [ "$IS_SWAP" -eq 0 ]; then - echo -e '\e[32mSwap not found. Adding swapfile.\e[0m' + echo 'Swap not found. Adding swapfile.' #RAM=$(awk '/MemTotal/ {print $2}' /proc/meminfo) #SWAP=$(($RAM * 2)) SWAP=8388608 - fallocate -l ${SWAP}k /swapfile + fallocate -l "${SWAP}k" /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo '/swapfile none swap defaults 0 0' >>/etc/fstab else - echo -e '\e[32mSwap found. No changes made.\e[0m' + echo 'Swap found. No changes made.' fi } -dappnode_start() { - echo -e "\e[32mDAppNode starting...\e[0m" 2>&1 | tee -a $LOGFILE - # shellcheck disable=SC1090 - source "${DAPPNODE_PROFILE}" >/dev/null 2>&1 +# Add .dappnode_profile sourcing to the user's default shell configuration +add_profile_to_shell() { + local user_home + local shell_configs - # Execute `compose-up` independently - # To execute `compose-up` against more than 1 compose, composes files must share compose file version (e.g 3.5) - for comp in "${DNCORE_YMLS_ARRAY[@]}"; do - docker compose -f "$comp" up -d 2>&1 | tee -a $LOGFILE - echo "${comp} started" 2>&1 | tee -a $LOGFILE - done - echo -e "\e[32mDAppNode started\e[0m" 2>&1 | tee -a $LOGFILE + if $IS_MACOS; then + user_home="$HOME" + # macOS defaults to zsh, but some users still run bash. + shell_configs=(".zshrc" ".zprofile" ".bashrc" ".bash_profile") + else + # Linux: determine user home from /etc/passwd + local user_name + user_name=$(grep 1000 /etc/passwd | cut -f 1 -d:) + if [ -n "$user_name" ]; then + user_home="/home/$user_name" + else + user_home="/root" + fi + shell_configs=(".profile" ".bashrc") + fi - # Show credentials to the user on login - USER=$(grep 1000 /etc/passwd | cut -f 1 -d:) - [ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root + for config_file in "${shell_configs[@]}"; do + local config_path="${user_home}/${config_file}" + local source_line + + # .profile may be evaluated by /bin/sh (dash on Debian/Ubuntu) where `source` is not valid. + # Use POSIX '.' there; use `source` elsewhere (bash/zsh). + if [ "$config_file" = ".profile" ]; then + source_line="[ -f \"${DAPPNODE_PROFILE}\" ] && . \"${DAPPNODE_PROFILE}\"" + else + source_line="[ -f \"${DAPPNODE_PROFILE}\" ] && source \"${DAPPNODE_PROFILE}\"" + fi - # Add profile sourcing to both .profile and .bashrc for maximum compatibility - for config_file in .profile .bashrc; do - CONFIG_PATH="$USER_HOME/$config_file" - # Create config file if it doesn't exist - [ ! -f "$CONFIG_PATH" ] && touch "$CONFIG_PATH" - + [ ! -f "$config_path" ] && touch "$config_path" # Add profile sourcing if not already present - if ! grep -q "${DAPPNODE_PROFILE}" "$CONFIG_PATH"; then - echo "######## DAPPNODE PROFILE ########" >>"$CONFIG_PATH" - echo -e "source ${DAPPNODE_PROFILE}\n" >>"$CONFIG_PATH" + if ! grep -q "${DAPPNODE_PROFILE}" "$config_path"; then + echo "######## DAPPNODE PROFILE ########" >> "$config_path" + echo "$source_line" >> "$config_path" + echo "" >> "$config_path" fi done +} + +dappnode_core_start() { + echo "DAppNode starting..." 2>&1 | tee -a "$LOGFILE" + + if [[ ${#DNCORE_COMPOSE_ARGS[@]} -eq 0 ]]; then + build_dncore_compose_args + fi + [[ ${#DNCORE_COMPOSE_ARGS[@]} -gt 0 ]] || die "No docker-compose-*.yml files found in ${DAPPNODE_CORE_DIR}" + + docker compose "${DNCORE_COMPOSE_ARGS[@]}" up -d 2>&1 | tee -a "$LOGFILE" + echo "DAppNode started" 2>&1 | tee -a "$LOGFILE" + + # Add profile sourcing to user's shell configuration + add_profile_to_shell - # Remove return from profile - sed -i '/return/d' $DAPPNODE_PROFILE | tee -a $LOGFILE + # Remove return from profile so it can be sourced in login shells + sed_inplace '/return/d' "$DAPPNODE_PROFILE" # Download access_credentials script - [ -f $DAPPNODE_ACCESS_CREDENTIALS ] || ${WGET} -O ${DAPPNODE_ACCESS_CREDENTIALS} ${DAPPNODE_ACCESS_CREDENTIALS_URL} + [ -f "$DAPPNODE_ACCESS_CREDENTIALS" ] || download_file "${DAPPNODE_ACCESS_CREDENTIALS}" "${DAPPNODE_ACCESS_CREDENTIALS_URL}" - # Delete dappnode_install.sh execution from rc.local if exists, and is not the unattended firstboot - if [ -f "/etc/rc.local" ] && [ ! -f "/usr/src/dappnode/.firstboot" ]; then - sed -i '/\/usr\/src\/dappnode\/scripts\/dappnode_install.sh/d' /etc/rc.local 2>&1 | tee -a $LOGFILE + # Linux-only: clean up rc.local + if $IS_LINUX; then + if [ -f "/etc/rc.local" ] && [ ! -f "${DAPPNODE_DIR}/.firstboot" ]; then + sed_inplace '/\/usr\/src\/dappnode\/scripts\/dappnode_install.sh/d' /etc/rc.local 2>&1 | tee -a "$LOGFILE" + fi fi # Display help message to the user - echo -e "Execute \e[32mdappnode_help\e[0m to see a full list with commands available" -} - -installExtraDpkg() { - if [ -d "/usr/src/dappnode/extra_dpkg" ]; then - dpkg -i /usr/src/dappnode/iso/extra_dpkg/*.deb 2>&1 | tee -a $LOGFILE - fi + echo "Execute dappnode_help to see a full list with commands available" } grabContentHashes() { if [ ! -f "${CONTENT_HASH_FILE}" ]; then - for comp in "${CONTENT_HASH_PKGS[@]}"; do - CONTENT_HASH=$(eval "${SWGET}" https://github.com/dappnode/DAppNodePackage-"${comp}"/releases/latest/download/content-hash) + local content_hash_pkgs=(geth besu nethermind erigon prysm teku lighthouse nimbus lodestar) + for comp in "${content_hash_pkgs[@]}"; do + CONTENT_HASH=$(download_stdout "https://github.com/dappnode/DAppNodePackage-${comp}/releases/latest/download/content-hash") if [ -z "$CONTENT_HASH" ]; then - echo "ERROR! Failed to find content hash of ${comp}." 2>&1 | tee -a $LOGFILE + echo "ERROR! Failed to find content hash of ${comp}." 2>&1 | tee -a "$LOGFILE" exit 1 fi - echo "${comp}.dnp.dappnode.eth,${CONTENT_HASH}" >>${CONTENT_HASH_FILE} + echo "${comp}.dnp.dappnode.eth,${CONTENT_HASH}" >>"${CONTENT_HASH_FILE}" done fi } @@ -338,15 +983,15 @@ grabContentHashes() { installSgx() { if [ -d "/usr/src/dappnode/iso/sgx" ]; then # from sgx_linux_x64_driver_2.5.0_2605efa.bin - /usr/src/dappnode/iso/sgx/sgx_linux_x64_driver.bin 2>&1 | tee -a $LOGFILE - /usr/src/dappnode/iso/sgx/enable_sgx 2>&1 | tee -a $LOGFILE + /usr/src/dappnode/iso/sgx/sgx_linux_x64_driver.bin 2>&1 | tee -a "$LOGFILE" + /usr/src/dappnode/iso/sgx/enable_sgx 2>&1 | tee -a "$LOGFILE" fi } # /extra_dpkg will only be installed on ISO's dappnode not on standalone script installExtraDpkg() { if [ -d "/usr/src/dappnode/iso/extra_dpkg" ]; then - dpkg -i /usr/src/dappnode/extra_dpkg/*.deb 2>&1 | tee -a $LOGFILE + dpkg -i /usr/src/dappnode/iso/extra_dpkg/*.deb 2>&1 | tee -a "$LOGFILE" fi } @@ -354,81 +999,112 @@ installExtraDpkg() { # Explained in: https://docs.docker.com/engine/install/linux-postinstall/ addUserToDockerGroup() { # UID is provided to the first regular user created in the system - USER=$(grep 1000 "/etc/passwd" | cut -f 1 -d:) + local user + user=$(grep 1000 "/etc/passwd" | cut -f 1 -d:) # If USER is not found, warn the user and return - if [ -z "$USER" ]; then - echo -e "\e[33mWARN: Default user not found. Could not add it to the docker group.\e[0m" 2>&1 | tee -a $LOGFILE + if [ -z "$user" ]; then + echo "WARN: Default user not found. Could not add it to the docker group." 2>&1 | tee -a "$LOGFILE" return fi - if groups "$USER" | grep &>/dev/null '\bdocker\b'; then - echo -e "\e[32mUser $USER is already in the docker group\e[0m" 2>&1 | tee -a $LOGFILE + if groups "$user" | grep &>/dev/null '\bdocker\b'; then + echo "User $user is already in the docker group" 2>&1 | tee -a "$LOGFILE" return fi # This step is already done in the dappnode_install_pre.sh script, # but it's not working in the Ubuntu ISO because the late-commands in the autoinstall.yaml # file are executed before the user is created. - usermod -aG docker "$USER" - echo -e "\e[32mUser $USER added to the docker group\e[0m" 2>&1 | tee -a $LOGFILE + usermod -aG docker "$user" + echo "User $user added to the docker group" 2>&1 | tee -a "$LOGFILE" } ############################################## #### SCRIPT START #### ############################################## -echo -e "\e[32m\n##############################################\e[0m" 2>&1 | tee -a $LOGFILE -echo -e "\e[32m#### DAPPNODE INSTALLER ####\e[0m" 2>&1 | tee -a $LOGFILE -echo -e "\e[32m##############################################\e[0m" 2>&1 | tee -a $LOGFILE +main() { + parse_args "$@" + validate_install_mode -echo -e "\e[32mCreating swap memory...\e[0m" 2>&1 | tee -a $LOGFILE -addSwap + bootstrap_filesystem + check_prereqs + configure_static_ip + ensure_profile_loaded + resolve_packages -echo -e "\e[32mCustomizing login...\e[0m" 2>&1 | tee -a $LOGFILE -customMotd + echo "" 2>&1 | tee -a "$LOGFILE" + echo "##############################################" 2>&1 | tee -a "$LOGFILE" + echo "#### DAPPNODE INSTALLER ####" 2>&1 | tee -a "$LOGFILE" + echo "##############################################" 2>&1 | tee -a "$LOGFILE" -echo -e "\e[32mInstalling extra packages...\e[0m" 2>&1 | tee -a $LOGFILE -installExtraDpkg + # --- Linux-only setup steps --- + if $IS_LINUX; then + if [[ "${MINIMAL}" != "true" && "${LITE}" != "true" ]]; then + echo "Creating swap memory..." 2>&1 | tee -a "$LOGFILE" + addSwap -echo -e "\e[32mGrabbing latest content hashes...\e[0m" 2>&1 | tee -a $LOGFILE -grabContentHashes + echo "Customizing login..." 2>&1 | tee -a "$LOGFILE" + customMotd -if [ "$ARCH" == "amd64" ]; then - echo -e "\e[32mInstalling SGX modules...\e[0m" 2>&1 | tee -a $LOGFILE - installSgx + echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE" + installExtraDpkg - echo -e "\e[32mInstalling extra packages...\e[0m" 2>&1 | tee -a $LOGFILE - installExtraDpkg # TODO: Why is this being called twice? -fi + echo "Grabbing latest content hashes..." 2>&1 | tee -a "$LOGFILE" + grabContentHashes -echo -e "\e[32mAdding user to docker group...\e[0m" 2>&1 | tee -a $LOGFILE -addUserToDockerGroup + if [ "$ARCH" == "amd64" ]; then + echo "Installing SGX modules..." 2>&1 | tee -a "$LOGFILE" + installSgx -echo -e "\e[32mCreating dncore_network if needed...\e[0m" 2>&1 | tee -a $LOGFILE -docker network create --driver bridge --subnet 172.33.0.0/16 dncore_network 2>&1 | tee -a $LOGFILE + echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE" + installExtraDpkg # TODO: Why is this being called twice? + fi + fi -echo -e "\e[32mBuilding DAppNode Core if needed...\e[0m" 2>&1 | tee -a $LOGFILE -dappnode_core_build + echo "Adding user to docker group..." 2>&1 | tee -a "$LOGFILE" + addUserToDockerGroup + fi -echo -e "\e[32mDownloading DAppNode Core...\e[0m" 2>&1 | tee -a $LOGFILE -dappnode_core_download + # --- Common steps (Linux and macOS) --- + echo "Creating dncore_network if needed..." 2>&1 | tee -a "$LOGFILE" + docker network create --driver bridge --subnet 172.33.0.0/16 dncore_network 2>&1 | tee -a "$LOGFILE" || true -echo -e "\e[32mLoading DAppNode Core...\e[0m" 2>&1 | tee -a $LOGFILE -dappnode_core_load + echo "Building DAppNode Core if needed..." 2>&1 | tee -a "$LOGFILE" + dappnode_core_build -if [ ! -f "/usr/src/dappnode/.firstboot" ]; then - echo -e "\e[32mDAppNode installed\e[0m" 2>&1 | tee -a $LOGFILE - dappnode_start -fi + echo "Downloading DAppNode Core..." 2>&1 | tee -a "$LOGFILE" + dappnode_core_download -# Run test in interactive terminal -if [ -f "/usr/src/dappnode/.firstboot" ]; then - # ensure openvt is installed prior to using it - apt-get update - apt-get install -y kbd - openvt -s -w -- sudo -u root /usr/src/dappnode/scripts/dappnode_test_install.sh - exit 0 -fi + # Build compose args now that compose files exist + build_dncore_compose_args + + echo "Loading DAppNode Core..." 2>&1 | tee -a "$LOGFILE" + dappnode_core_load + + # --- Start DAppNode --- + if $IS_LINUX; then + if [ ! -f "${DAPPNODE_DIR}/.firstboot" ]; then + echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE" + dappnode_core_start + print_vpn_access_credentials + fi + + # Run test in interactive terminal (first boot only) + if [ -f "${DAPPNODE_DIR}/.firstboot" ]; then + apt-get update + apt-get install -y kbd + openvt -s -w -- sudo -u root "${DAPPNODE_DIR}/scripts/dappnode_test_install.sh" + exit 0 + fi + fi + + if $IS_MACOS; then + echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE" + dappnode_core_start + print_vpn_access_credentials + fi +} -exit 0 +main "$@" diff --git a/scripts/dappnode_uninstall.sh b/scripts/dappnode_uninstall.sh index 66bc9f35..29da4a5e 100755 --- a/scripts/dappnode_uninstall.sh +++ b/scripts/dappnode_uninstall.sh @@ -1,21 +1,72 @@ #!/usr/bin/env bash -DAPPNODE_DIR="/usr/src/dappnode" + +# This uninstaller is written for bash. It's safe to *run it from zsh* (it will execute via bash +# thanks to the shebang), but users sometimes invoke it as `zsh ./script.sh` or `source ./script.sh`. +# - If sourced, bail out (sourcing would pollute the current shell and can break it). +# - If invoked by a non-bash shell, re-exec with bash before hitting bash-specific builtins. +if (return 0 2>/dev/null); then + echo "This script must be executed, not sourced. Run: bash $0" + return 1 +fi + +if [ -z "${BASH_VERSION:-}" ]; then + exec /usr/bin/env bash "$0" "$@" +fi + +################## +# OS DETECTION # +################## +OS_TYPE="$(uname -s)" +IS_MACOS=false +IS_LINUX=false +if [[ "$OS_TYPE" == "Darwin" ]]; then + IS_MACOS=true +elif [[ "$OS_TYPE" == "Linux" ]]; then + IS_LINUX=true +else + echo "Unsupported operating system: $OS_TYPE" + exit 1 +fi + +############# +# VARIABLES # +############# +# Dirs — macOS uses $HOME/dappnode, Linux uses /usr/src/dappnode (mirrors install script) +if $IS_MACOS; then + DAPPNODE_DIR="$HOME/dappnode" +else + DAPPNODE_DIR="/usr/src/dappnode" +fi DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE" PROFILE_FILE="${DAPPNODE_CORE_DIR}/.dappnode_profile" input=$1 # Allow to call script with argument (must be Y/N) -[ -f $PROFILE_FILE ] || ( - echo "Error: DAppNode profile does not exist." +############################## +# Cross-platform Helpers # +############################## + +# Cross-platform in-place sed (macOS requires '' after -i) +sed_inplace() { + if $IS_MACOS; then + sed -i '' "$@" + else + sed -i "$@" + fi +} + +[ -f "$PROFILE_FILE" ] || { + echo "Error: DAppNode profile does not exist at ${PROFILE_FILE}." exit 1 -) +} uninstall() { - echo -e "\e[32mUninstalling DAppNode\e[0m" + echo "Uninstalling DAppNode" # shellcheck disable=SC1090 source "${PROFILE_FILE}" &>/dev/null DAPPNODE_CONTAINERS="$(docker ps -a --format '{{.Names}}' | grep DAppNode)" - echo -e "\e[32mRemoving DAppNode containers: \e[0m\n${DAPPNODE_CONTAINERS}" + echo "Removing DAppNode containers: " + echo "${DAPPNODE_CONTAINERS}" for container in $DAPPNODE_CONTAINERS; do # Stop DAppNode container docker stop "$container" &>/dev/null @@ -24,40 +75,58 @@ uninstall() { done DAPPNODE_IMAGES="$(docker image ls -a | grep "dappnode")" - echo -e "\e[32mRemoving DAppNode images: \e[0m\n${DAPPNODE_IMAGES}" + echo "Removing DAppNode images: " + echo "${DAPPNODE_IMAGES}" for image in $DAPPNODE_IMAGES; do # Remove DAppNode images docker image rm "$image" &>/dev/null done DAPPNODE_VOLUMES="$(docker volume ls | grep "dappnode\|dncore")" - echo -e "\e[32mRemoving DAppNode volumes: \e[0m\n${DAPPNODE_VOLUMES}" + echo "Removing DAppNode volumes: " + echo "${DAPPNODE_VOLUMES}" for volume in $DAPPNODE_VOLUMES; do # Remove DAppNode volumes docker volume rm "$volume" &>/dev/null done # Remove dncore_network - echo -e "\e[32mRemoving docker dncore_network\e[0m" + echo "Removing docker dncore_network" docker network remove dncore_network || echo "dncore_network already removed" - # Remove dir - echo -e "\e[32mRemoving DAppNode directory\e[0m" - rm -rf /usr/src/dappnode + # Remove DAppNode directory + echo "Removing DAppNode directory: ${DAPPNODE_DIR}" + rm -rf "${DAPPNODE_DIR}" # Remove profile file references from shell config files - USER=$(grep 1000 /etc/passwd | cut -f 1 -d:) - [ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root - - for config_file in .profile .bashrc; do - CONFIG_PATH="$USER_HOME/$config_file" - if [ -f "$CONFIG_PATH" ]; then - sed -i '/######## DAPPNODE PROFILE ########/d' "$CONFIG_PATH" - sed -i '/.*dappnode_profile/d' "$CONFIG_PATH" + local user_home + local shell_configs + + if $IS_MACOS; then + user_home="$HOME" + # macOS defaults to zsh — matches install script + shell_configs=(".zshrc" ".zprofile") + else + local user_name + user_name=$(grep 1000 /etc/passwd | cut -f 1 -d:) + if [ -n "$user_name" ]; then + user_home="/home/$user_name" + else + user_home="/root" + fi + shell_configs=(".profile" ".bashrc") + fi + + # Remove Dappnode profile references from shell config files + for config_file in "${shell_configs[@]}"; do + local config_path="${user_home}/${config_file}" + if [ -f "$config_path" ]; then + sed_inplace '/######## DAPPNODE PROFILE ########/d' "$config_path" + sed_inplace '/.*dappnode_profile/d' "$config_path" fi done - echo -e "\e[32mDAppNode uninstalled!\e[0m" + echo "DAppNode uninstalled!" } if [ $# -eq 0 ]; then From aa7e0e2e65e4e378e31574cc01f02c1578659e96 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Mon, 9 Mar 2026 09:57:32 +0100 Subject: [PATCH 04/19] Add notifications and premium package versions to CHANGELOG.md (#697) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad7c934e..f6cd00b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -241,7 +241,7 @@ jobs: SHASUM_DEBIAN_ATTENDED=$(cat SHASUM_DEBIAN_ATTENDED.txt) SHASUM_DEBIAN_UNATTENDED=$(cat SHASUM_DEBIAN_UNATTENDED.txt) SHASUM_UBUNTU_UNATTENDED=$(cat SHASUM_UBUNTU_UNATTENDED.txt) - echo -en "# Versions\n| Package | Version |\n|---|---|\nbind.dnp.dappnode.eth|${{ needs.set-versions.outputs.bind }}|\n|ipfs.dnp.dappnode.eth|${{ needs.set-versions.outputs.ipfs }}|\n|vpn.dnp.dappnode.eth |${{ needs.set-versions.outputs.vpn }}|\n|dappmanager.dnp.dappnode.eth|${{ needs.set-versions.outputs.dappmanager }}|\n|wifi.dnp.dappnode.eth|${{ needs.set-versions.outputs.wifi }}|\n|https.dnp.dappnode.eth|${{ needs.set-versions.outputs.https }}|\n|wireguard.dnp.dappnode.eth|${{ needs.set-versions.outputs.wireguard }}|\n# Changes\nChanges implemented in release ${{ needs.set-versions.outputs.core }}\n# Debian Attended version\nInstall and customize DAppNode using the attended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso\n$SHASUM_DEBIAN_ATTENDED\n```\n# Debian Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso**\nDo a reboot right after the installation\n:warning: **Warning**: This ISO will install Dappnode automatically, deleting all existing partitions on the disk\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso\n$SHASUM_DEBIAN_UNATTENDED\n```\n# Ubuntu Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso\n$SHASUM_UBUNTU_UNATTENDED\n```\nUploaded at https://ubuntu.iso.dappnode.io\n# DAppNode for Raspberry Pi 4 64bit\n[Instructions](https://github.com/dappnode/DAppNode/wiki/DAppNodeARM-Installation-Guide)\n\ndefault login data:\n - **__user__**: dappnode\n - **__password__**: dappnodepi" > CHANGELOG.md + echo -en "# Versions\n| Package | Version |\n|---|---|\nbind.dnp.dappnode.eth|${{ needs.set-versions.outputs.bind }}|\n|ipfs.dnp.dappnode.eth|${{ needs.set-versions.outputs.ipfs }}|\n|vpn.dnp.dappnode.eth |${{ needs.set-versions.outputs.vpn }}|\n|dappmanager.dnp.dappnode.eth|${{ needs.set-versions.outputs.dappmanager }}|\n|wifi.dnp.dappnode.eth|${{ needs.set-versions.outputs.wifi }}|\n|https.dnp.dappnode.eth|${{ needs.set-versions.outputs.https }}|\n|wireguard.dnp.dappnode.eth|${{ needs.set-versions.outputs.wireguard }}|\n|notifications.dnp.dappnode.eth|${{ needs.set-versions.outputs.notifications }}|\n|premium.dnp.dappnode.eth|${{ needs.set-versions.outputs.premium }}|\n# Changes\nChanges implemented in release ${{ needs.set-versions.outputs.core }}\n# Debian Attended version\nInstall and customize DAppNode using the attended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso\n$SHASUM_DEBIAN_ATTENDED\n```\n# Debian Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso**\nDo a reboot right after the installation\n:warning: **Warning**: This ISO will install Dappnode automatically, deleting all existing partitions on the disk\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso\n$SHASUM_DEBIAN_UNATTENDED\n```\n# Ubuntu Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso\n$SHASUM_UBUNTU_UNATTENDED\n```\nUploaded at https://ubuntu.iso.dappnode.io\n# DAppNode for Raspberry Pi 4 64bit\n[Instructions](https://github.com/dappnode/DAppNode/wiki/DAppNodeARM-Installation-Guide)\n\ndefault login data:\n - **__user__**: dappnode\n - **__password__**: dappnodepi" > CHANGELOG.md cat CHANGELOG.md - name: Print images directory run: | From 50957c3a20969d5f3aa97f798882860f840994d2 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Tue, 17 Mar 2026 07:47:18 +0100 Subject: [PATCH 05/19] Add final sleep seconds parameter to wait_for_internal_ip function (#700) --- scripts/dappnode_install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/dappnode_install.sh b/scripts/dappnode_install.sh index 0f6e4ab0..32f82f95 100755 --- a/scripts/dappnode_install.sh +++ b/scripts/dappnode_install.sh @@ -172,11 +172,12 @@ check_prereqs() { # Wait until dappmanager publishes INTERNAL_IP via its local HTTP endpoint. # Runs the curl inside the provided container and exits with error on timeout. -# Usage: wait_for_internal_ip [timeout_seconds] [initial_sleep_seconds] +# Usage: wait_for_internal_ip [timeout_seconds] [initial_sleep_seconds] [final_sleep_seconds] wait_for_internal_ip() { local container_name="$1" local timeout_seconds="${2:-120}" local initial_sleep_seconds="${3:-10}" + local final_sleep_seconds="${4:-2}" local internal_ip_url="http://127.0.0.1/global-envs/INTERNAL_IP" local hostname_url="http://127.0.0.1/global-envs/HOSTNAME" @@ -214,7 +215,7 @@ wait_for_internal_ip() { hostname_value="$(printf '%s\n' "$hostname_result" | head -n 1 | tr -d '\r' | xargs)" if [[ "$internal_http_code" == "200" && -n "$internal_value" && "$internal_value" != "null" && "$hostname_http_code" == "200" && -n "$hostname_value" && "$hostname_value" != "null" ]]; then - sleep 2 # Extra buffer to ensure values are fully propagated before we proceed + sleep "$final_sleep_seconds" # Extra buffer to ensure values are fully propagated before we proceed echo "INTERNAL_IP is ready: $internal_value" echo "HOSTNAME is ready: $hostname_value" return 0 @@ -253,7 +254,7 @@ print_vpn_access_credentials() { echo "" echo "Waiting for VPN initialization..." - wait_for_internal_ip "DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 20 + wait_for_internal_ip "DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 20 10 echo "" echo "##############################################" From d00bc0b50c1649b0c5bb1ba0b758bf0167925d34 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:25:45 +0100 Subject: [PATCH 06/19] Add port conflict checks for HTTPS and VPN in installer script (#701) * Add port conflict checks for HTTPS and VPN in installer script * Update notifications and premium package versions in .dappnode_profile * Refactor logging in dappnode_install.sh to use log function for consistency * Update package versions in .dappnode_profile for consistency * Enhance logging and retry mechanism in wait_for_internal_ip function; update warnings for credential availability * Update IPFS endpoint URL in dappnode_install.sh for stability * Update notifications and premium package versions in .dappnode_profile for consistency --- .dappnode_profile | 16 +-- scripts/dappnode_install.sh | 279 +++++++++++++++++++++++------------- 2 files changed, 184 insertions(+), 111 deletions(-) diff --git a/.dappnode_profile b/.dappnode_profile index ece7e1bd..4d4943b8 100755 --- a/.dappnode_profile +++ b/.dappnode_profile @@ -7,15 +7,15 @@ # - `/ipfs/QmRe6...` -> indicates the ipfs hash used to download the content # - `0.2.71` -> indicates the version. It must be the one uploaded to such IPFS hash -export BIND_VERSION="${BIND_VERSION:-0.2.11}" -export IPFS_VERSION="${IPFS_VERSION:-0.2.23}" -export VPN_VERSION="${VPN_VERSION:-0.2.10}" -export DAPPMANAGER_VERSION="${DAPPMANAGER_VERSION:-0.2.99}" -export WIFI_VERSION="${WIFI_VERSION:-0.2.9}" -export WIREGUARD_VERSION="${WIREGUARD_VERSION:-0.1.3}" +export BIND_VERSION="${BIND_VERSION:-0.2.13}" +export IPFS_VERSION="${IPFS_VERSION:-0.2.27}" +export VPN_VERSION="${VPN_VERSION:-0.2.11}" +export DAPPMANAGER_VERSION="${DAPPMANAGER_VERSION:-0.2.121}" +export WIFI_VERSION="${WIFI_VERSION:-0.2.11}" +export WIREGUARD_VERSION="${WIREGUARD_VERSION:-0.1.4}" export HTTPS_VERSION="${HTTPS:-0.2.2}" -export NOTIFICATIONS_VERSION="/ipfs/QmQubxH4WgqEFxvFntef4H2DmuU6mxBRS6XeuShc3owNi9" -export PREMIUM_VERSION="/ipfs/QmXDddoa56HkrvtkGsa3mozpsn9SzQZtoVBWgagcW6SsHy" +export NOTIFICATIONS_VERSION="/ipfs/QmW5CSZv8x8ZktiNodJ9P8M6ZSRNX93jmB8oU6RtGermBc" +export PREMIUM_VERSION="/ipfs/QmUEmjt1yXLyGjnqf3BCiVenQtDhFwt4eMkx1sDemeEidM" export DAPPNODE_DIR="/usr/src/dappnode" export DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE" diff --git a/scripts/dappnode_install.sh b/scripts/dappnode_install.sh index 32f82f95..0379827a 100755 --- a/scripts/dappnode_install.sh +++ b/scripts/dappnode_install.sh @@ -4,9 +4,56 @@ # thanks to the shebang), but users sometimes invoke it as `zsh ./script.sh` or `source ./script.sh`. # - If sourced, bail out (sourcing would pollute the current shell and can break it). # - If invoked by a non-bash shell, re-exec with bash before hitting bash-specific builtins. + +############################## +# Logging / Errors # +############################## +# Note: LOGFILE and LOGS_DIR are set during bootstrap_filesystem based on DAPPNODE_DIR +# Early definition allows these functions to be used throughout the script. + +log() { + # LOGFILE is created after dir bootstrap; until then we just print to stdout. + if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then + printf '%s\n' "[INFO] $*" | tee -a "$LOGFILE" + else + printf '%s\n' "[INFO] $*" + fi +} + +warn() { + # LOGFILE is created after dir bootstrap; until then we just print to stdout. + if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then + printf '%s\n' "[WARN] $*" | tee -a "$LOGFILE" + else + printf '%s\n' "[WARN] $*" + fi +} + +error() { + # LOGFILE is created after dir bootstrap; until then we just print to stdout. + if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then + printf '%s\n' "[ERROR] $*" | tee -a "$LOGFILE" + else + printf '%s\n' "[ERROR] $*" + fi +} + +die() { + # LOGFILE is created after dir bootstrap; until then we just print to stdout. + if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then + printf '%s\n' "[ERROR] $*" | tee -a "$LOGFILE" + else + printf '%s\n' "[ERROR] $*" + fi + exit 1 +} + +############################## +# Script Guards # +############################## + if (return 0 2>/dev/null); then - echo "This script must be executed, not sourced. Run: bash $0" - return 1 + die "This script must be executed, not sourced. Run: bash $0" fi if [ -z "${BASH_VERSION:-}" ]; then @@ -30,28 +77,6 @@ shopt -s expand_aliases # Ensure array is always defined (avoid `set -u` edge cases) DNCORE_COMPOSE_ARGS=() -############################## -# Logging / Errors # -############################## - -log() { - # LOGFILE is created after dir bootstrap; until then we just print to stdout. - if [[ -n "${LOGFILE:-}" && -d "${LOGS_DIR:-}" ]]; then - printf '%s\n' "$*" | tee -a "$LOGFILE" - else - printf '%s\n' "$*" - fi -} - -warn() { - log "[WARN] $*" -} - -die() { - log "[ERROR] $*" - exit 1 -} - usage() { cat <<'EOF' Usage: dappnode_install.sh [options] @@ -181,7 +206,7 @@ wait_for_internal_ip() { local internal_ip_url="http://127.0.0.1/global-envs/INTERNAL_IP" local hostname_url="http://127.0.0.1/global-envs/HOSTNAME" - echo "Waiting for dappmanager to publish INTERNAL_IP and HOSTNAME..." + log "Waiting for dappmanager to publish INTERNAL_IP and HOSTNAME..." sleep "$initial_sleep_seconds" local start_seconds internal_http_code internal_value internal_result @@ -191,6 +216,7 @@ wait_for_internal_ip() { internal_value="" hostname_http_code="" hostname_value="" + local retry_count=0 while true; do if (( SECONDS - start_seconds >= timeout_seconds )); then @@ -216,12 +242,15 @@ wait_for_internal_ip() { if [[ "$internal_http_code" == "200" && -n "$internal_value" && "$internal_value" != "null" && "$hostname_http_code" == "200" && -n "$hostname_value" && "$hostname_value" != "null" ]]; then sleep "$final_sleep_seconds" # Extra buffer to ensure values are fully propagated before we proceed - echo "INTERNAL_IP is ready: $internal_value" - echo "HOSTNAME is ready: $hostname_value" + log "INTERNAL_IP is ready: $internal_value" + log "HOSTNAME is ready: $hostname_value" return 0 fi - echo "INTERNAL_IP/HOSTNAME not ready yet (INTERNAL_IP code=${internal_http_code:-?}, HOSTNAME code=${hostname_http_code:-?}). Retrying..." + retry_count=$((retry_count + 1)) + if (( retry_count % 5 == 1 )); then + log "INTERNAL_IP/HOSTNAME not ready yet (INTERNAL_IP code=${internal_http_code:-?}, HOSTNAME code=${hostname_http_code:-?}). Retrying..." + fi sleep 2 done } @@ -247,43 +276,42 @@ print_vpn_access_credentials() { done if [[ "$has_wireguard" != "true" && "$has_vpn" != "true" ]]; then - echo "" - echo "No VPN package selected (VPN/WIREGUARD). Skipping credentials output." + log "No VPN package selected (VPN/WIREGUARD). Skipping credentials output." return 0 fi - echo "" - echo "Waiting for VPN initialization..." + log "" + log "Waiting for VPN initialization..." wait_for_internal_ip "DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 20 10 - echo "" - echo "##############################################" - echo "# DAppNode VPN Access Credentials #" - echo "##############################################" - echo "" - echo "Your DAppNode is ready! Connect using your preferred VPN client." - echo "Choose either Wireguard (recommended) or OpenVPN and import the" - echo "credentials below into your VPN app to access your DAppNode." - echo "" + log "" + log "##############################################" + log "# DAppNode VPN Access Credentials #" + log "##############################################" + log "" + log "Your DAppNode is ready! Connect using your preferred VPN client." + log "Choose either Wireguard (recommended) or OpenVPN and import the" + log "credentials below into your VPN app to access your DAppNode." + log "" if [[ "$has_wireguard" == "true" ]]; then - echo "--- Wireguard ---" + log "--- Wireguard ---" docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials "${localhost_flag[@]}" 2>&1 || \ - echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard${localhost_flag:+ ${localhost_flag[*]}}" + warn "Wireguard credentials not yet available. Try later with: dappnode_wireguard${localhost_flag:+ ${localhost_flag[*]}}" fi if [[ "$has_wireguard" == "true" && "$has_vpn" == "true" ]]; then - echo "" + log "" fi if [[ "$has_vpn" == "true" ]]; then - echo "--- OpenVPN ---" + log "--- OpenVPN ---" docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get dappnode_admin "${localhost_flag[@]}" 2>&1 || \ - echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin${localhost_flag:+ ${localhost_flag[*]}}" + warn "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin${localhost_flag:+ ${localhost_flag[*]}}" fi - echo "" - echo "Import the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode" + log "" + log "Import the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode" } # Build docker compose "-f " args from downloaded compose files. @@ -332,7 +360,7 @@ if $IS_LINUX; then UPDATE_MOTD_DIR="/etc/update-motd.d" fi # Get URLs -IPFS_ENDPOINT=${IPFS_ENDPOINT:-"https://ipfs-gateway-dev.dappnode.net"} +IPFS_ENDPOINT=${IPFS_ENDPOINT:-"https://ipfs-gateway.dappnode.net"} # PROFILE_URL env is used to fetch the core packages versions that will be used to build the release in script install method PROFILE_URL=${PROFILE_URL:-"https://github.com/dappnode/DAppNode/releases/latest/download/dappnode_profile.sh"} DAPPNODE_ACCESS_CREDENTIALS="${DAPPNODE_DIR}/scripts/dappnode_access_credentials.sh" @@ -402,8 +430,8 @@ normalize_ipfs_version_ref() { local manifest manifest="$(download_stdout "$manifest_url" 2>/dev/null || true)" if [[ -z "$manifest" ]]; then - echo "[ERROR] Could not fetch IPFS manifest for ${comp} from: $manifest_url" 1>&2 - echo "[ERROR] Provide ${comp}_VERSION as /ipfs/: (example: /ipfs/Qm...:0.2.11)" 1>&2 + error "Could not fetch IPFS manifest for ${comp} from: $manifest_url" + error "Provide ${comp}_VERSION as /ipfs/: (example: /ipfs/Qm...:0.2.11)" return 1 fi @@ -416,8 +444,8 @@ normalize_ipfs_version_ref() { )" if [[ -z "$inferred_version" || "$inferred_version" == "$manifest" ]]; then - echo "[ERROR] Could not infer version for ${comp} from IPFS manifest: $manifest_url" 1>&2 - echo "[ERROR] Provide ${comp}_VERSION as /ipfs/:" 1>&2 + error "Could not infer version for ${comp} from IPFS manifest: $manifest_url" + error "Provide ${comp}_VERSION as /ipfs/:" return 1 fi @@ -501,7 +529,7 @@ patch_dappmanager_compose_for_macos() { bootstrap_filesystem() { # Clean if update if [[ "${UPDATE}" == "true" ]]; then - echo "Cleaning for update..." + log "Cleaning for update..." rm -f "${LOGFILE}" || true rm -f "${DAPPNODE_CORE_DIR}"/docker-compose-*.yml || true rm -f "${DAPPNODE_CORE_DIR}"/dappnode_package-*.json || true @@ -523,35 +551,79 @@ bootstrap_filesystem() { touch "${LOGFILE}" || true } -# Check if port 80 is in use (necessary for HTTPS) -# Returns IS_PORT_USED=true only if port 80 or 443 is used by something OTHER than our HTTPS container -is_port_used() { - # Check if port 80 or 443 is in use at all - local port80_used port443_used - if command -v lsof >/dev/null 2>&1; then - lsof -i -P -n | grep ":80 (LISTEN)" &>/dev/null && port80_used=true || port80_used=false - lsof -i -P -n | grep ":443 (LISTEN)" &>/dev/null && port443_used=true || port443_used=false +# Generic helper: returns 0 if a process is bound to the given port, 1 if not. +# Usage: is_port_listening [tcp|udp] +# tcp (default): matches TCP sockets in LISTEN state +# udp: matches any process bound to the UDP port +is_port_listening() { + local port="$1" + local proto="${2:-tcp}" + if [[ "$proto" == "udp" ]]; then + lsof -i "udp:${port}" -P -n 2>/dev/null | grep -q . else + lsof -i "tcp:${port}" -P -n 2>/dev/null | grep -q "(LISTEN)" + fi +} + +# Check if ports 80/443 are occupied by something other than our own HTTPS container. +# Sets HTTPS_PORTS_BLOCKED=true/false. +check_https_ports_conflict() { + if ! command -v lsof >/dev/null 2>&1; then warn "lsof not found; assuming ports 80/443 are in use (HTTPS will be skipped)" - IS_PORT_USED=true + HTTPS_PORTS_BLOCKED=true return fi - if [ "$port80_used" = false ] && [ "$port443_used" = false ]; then - IS_PORT_USED=false + if ! is_port_listening 80 && ! is_port_listening 443; then + HTTPS_PORTS_BLOCKED=false return fi - # If either port is in use, check if it's our HTTPS container + # Port 80 or 443 is in use; check if it's our own HTTPS container if docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^DAppNodeCore-https.dnp.dappnode.eth$"; then - # Port 80 or 443 is used by our HTTPS container, so we consider it "not used" for package determination - IS_PORT_USED=false + # Our own HTTPS container already holds the port — not a conflict + HTTPS_PORTS_BLOCKED=false else # Port 80 or 443 is used by something else - IS_PORT_USED=true + HTTPS_PORTS_BLOCKED=true fi } +# Check that ports required by VPN/Wireguard are not already in use by another process. +# Must be called after PKGS is populated. Exits with a helpful error on conflict. +check_vpn_ports_conflict() { + if ! command -v lsof >/dev/null 2>&1; then + return # cannot check; proceed and let the container report a bind error + fi + + local pkg + for pkg in "${PKGS[@]}"; do + case "$pkg" in + WIREGUARD) + if is_port_listening 51820 udp; then + error "Port 51820/UDP is already in use on this host." + error "This port is required by the Wireguard package and must be free before installing." + error "Free up port 51820 and re-run the installer, or — if you do not need VPN" + error "connectivity — consider using --minimal instead (advanced users only)." + exit 1 + fi + ;; + VPN) + local vpn_blocked=() + is_port_listening 1194 udp && vpn_blocked+=(1194/UDP) + is_port_listening 8092 tcp && vpn_blocked+=(8092/TCP) + if [[ ${#vpn_blocked[@]} -gt 0 ]]; then + error "Port(s) ${vpn_blocked[*]} are already in use on this host." + error "These ports are required by the OpenVPN package and must be free before installing." + error "Free up the port(s) and re-run the installer, or — if you do not need VPN" + error "connectivity — consider using --minimal instead (advanced users only)." + exit 1 + fi + ;; + esac + done +} + # Determine packages to be installed determine_packages() { # Explicit package list override from flag/env always has top priority. @@ -649,8 +721,8 @@ determine_packages() { # Default mode (no --packages/--minimal/--lite): install full package set. # HTTPS is included only when ports 80/443 are available. - is_port_used - if [ "$IS_PORT_USED" == "true" ]; then + check_https_ports_conflict + if [ "$HTTPS_PORTS_BLOCKED" == "true" ]; then PKGS=(BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM) else PKGS=(HTTPS BIND IPFS VPN WIREGUARD DAPPMANAGER WIFI NOTIFICATIONS PREMIUM) @@ -710,6 +782,7 @@ resolve_packages() { # If such variable with 'dev:'' suffix is used, then the component is built from specified branch or commit. # you can also specify an IPFS version like /ipfs/: (the exact version is required). determine_packages + check_vpn_ports_conflict for comp in "${PKGS[@]}"; do ver="${comp}_VERSION" log "Processing $comp: ${!ver-}" @@ -741,17 +814,17 @@ dappnode_core_build() { ver="${comp}_VERSION" if [[ ${!ver} == dev:* ]]; then if $IS_MACOS; then - echo "Development builds (dev:*) are not supported on macOS." + error "Development builds (dev:*) are not supported on macOS." exit 1 fi - echo "Cloning & building DNP_${comp}..." + log "Cloning & building DNP_${comp}..." if ! dpkg -s git >/dev/null 2>&1; then apt-get install -y git fi local tmpdir tmpdir="$(mktemp -d)" pushd "$tmpdir" >/dev/null || { - echo "Error on pushd" + error "Error on pushd" exit 1 } git clone -b "${!ver##*:}" https://github.com/dappnode/DNP_"${comp}" @@ -765,7 +838,7 @@ dappnode_core_build() { cp "./DNP_${comp}/dappnode_package.json" "${DAPPNODE_CORE_DIR}/dappnode_package-${comp_lower}.json" rm -rf "./DNP_${comp}" popd >/dev/null || { - echo "Error on popd" + error "Error on popd" exit 1 } rm -rf "$tmpdir" @@ -785,13 +858,13 @@ dappnode_core_download() { local manifest_var="${comp}_MANIFEST" # Download DAppNode Core Images if needed - echo "Downloading ${comp} tar..." + log "Downloading ${comp} tar..." [ -f "${!file_var}" ] || download_file "${!file_var}" "${!url_var}" || exit 1 # Download DAppNode Core docker-compose yml files if needed - echo "Downloading ${comp} yml..." + log "Downloading ${comp} yml..." [ -f "${!yml_file_var}" ] || download_file "${!yml_file_var}" "${!yml_var}" || exit 1 # Download DAppNode Core manifest files if needed - echo "Downloading ${comp} manifest..." + log "Downloading ${comp} manifest..." [ -f "${!manifest_file_var}" ] || download_file "${!manifest_file_var}" "${!manifest_var}" || exit 1 # macOS: patch compose files for Docker Desktop compatibility @@ -877,7 +950,7 @@ addSwap() { # if not then create it if [ "$IS_SWAP" -eq 0 ]; then - echo 'Swap not found. Adding swapfile.' + log 'Swap not found. Adding swapfile.' #RAM=$(awk '/MemTotal/ {print $2}' /proc/meminfo) #SWAP=$(($RAM * 2)) SWAP=8388608 @@ -887,7 +960,7 @@ addSwap() { swapon /swapfile echo '/swapfile none swap defaults 0 0' >>/etc/fstab else - echo 'Swap found. No changes made.' + log 'Swap found. No changes made.' fi } @@ -936,7 +1009,7 @@ add_profile_to_shell() { } dappnode_core_start() { - echo "DAppNode starting..." 2>&1 | tee -a "$LOGFILE" + log "DAppNode starting..." if [[ ${#DNCORE_COMPOSE_ARGS[@]} -eq 0 ]]; then build_dncore_compose_args @@ -944,7 +1017,7 @@ dappnode_core_start() { [[ ${#DNCORE_COMPOSE_ARGS[@]} -gt 0 ]] || die "No docker-compose-*.yml files found in ${DAPPNODE_CORE_DIR}" docker compose "${DNCORE_COMPOSE_ARGS[@]}" up -d 2>&1 | tee -a "$LOGFILE" - echo "DAppNode started" 2>&1 | tee -a "$LOGFILE" + log "DAppNode started" # Add profile sourcing to user's shell configuration add_profile_to_shell @@ -963,7 +1036,7 @@ dappnode_core_start() { fi # Display help message to the user - echo "Execute dappnode_help to see a full list with commands available" + log "Execute dappnode_help to see a full list with commands available" } grabContentHashes() { @@ -972,7 +1045,7 @@ grabContentHashes() { for comp in "${content_hash_pkgs[@]}"; do CONTENT_HASH=$(download_stdout "https://github.com/dappnode/DAppNodePackage-${comp}/releases/latest/download/content-hash") if [ -z "$CONTENT_HASH" ]; then - echo "ERROR! Failed to find content hash of ${comp}." 2>&1 | tee -a "$LOGFILE" + error "Failed to find content hash of ${comp}." exit 1 fi echo "${comp}.dnp.dappnode.eth,${CONTENT_HASH}" >>"${CONTENT_HASH_FILE}" @@ -1005,12 +1078,12 @@ addUserToDockerGroup() { # If USER is not found, warn the user and return if [ -z "$user" ]; then - echo "WARN: Default user not found. Could not add it to the docker group." 2>&1 | tee -a "$LOGFILE" + warn "Default user not found. Could not add it to the docker group." return fi if groups "$user" | grep &>/dev/null '\bdocker\b'; then - echo "User $user is already in the docker group" 2>&1 | tee -a "$LOGFILE" + log "User $user is already in the docker group" return fi @@ -1018,7 +1091,7 @@ addUserToDockerGroup() { # but it's not working in the Ubuntu ISO because the late-commands in the autoinstall.yaml # file are executed before the user is created. usermod -aG docker "$user" - echo "User $user added to the docker group" 2>&1 | tee -a "$LOGFILE" + log "User $user added to the docker group" } ############################################## @@ -1036,58 +1109,58 @@ main() { resolve_packages echo "" 2>&1 | tee -a "$LOGFILE" - echo "##############################################" 2>&1 | tee -a "$LOGFILE" - echo "#### DAPPNODE INSTALLER ####" 2>&1 | tee -a "$LOGFILE" - echo "##############################################" 2>&1 | tee -a "$LOGFILE" + log "##############################################" + log "#### DAPPNODE INSTALLER ####" + log "##############################################" # --- Linux-only setup steps --- if $IS_LINUX; then if [[ "${MINIMAL}" != "true" && "${LITE}" != "true" ]]; then - echo "Creating swap memory..." 2>&1 | tee -a "$LOGFILE" + log "Creating swap memory..." addSwap - echo "Customizing login..." 2>&1 | tee -a "$LOGFILE" + log "Customizing login..." customMotd - echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE" + log "Installing extra packages..." installExtraDpkg - echo "Grabbing latest content hashes..." 2>&1 | tee -a "$LOGFILE" + log "Grabbing latest content hashes..." grabContentHashes if [ "$ARCH" == "amd64" ]; then - echo "Installing SGX modules..." 2>&1 | tee -a "$LOGFILE" + log "Installing SGX modules..." installSgx - echo "Installing extra packages..." 2>&1 | tee -a "$LOGFILE" + log "Installing extra packages..." installExtraDpkg # TODO: Why is this being called twice? fi fi - echo "Adding user to docker group..." 2>&1 | tee -a "$LOGFILE" + log "Adding user to docker group..." addUserToDockerGroup fi # --- Common steps (Linux and macOS) --- - echo "Creating dncore_network if needed..." 2>&1 | tee -a "$LOGFILE" + log "Creating dncore_network if needed..." docker network create --driver bridge --subnet 172.33.0.0/16 dncore_network 2>&1 | tee -a "$LOGFILE" || true - echo "Building DAppNode Core if needed..." 2>&1 | tee -a "$LOGFILE" + log "Building DAppNode Core if needed..." dappnode_core_build - echo "Downloading DAppNode Core..." 2>&1 | tee -a "$LOGFILE" + log "Downloading DAppNode Core..." dappnode_core_download # Build compose args now that compose files exist build_dncore_compose_args - echo "Loading DAppNode Core..." 2>&1 | tee -a "$LOGFILE" + log "Loading DAppNode Core..." dappnode_core_load # --- Start DAppNode --- if $IS_LINUX; then if [ ! -f "${DAPPNODE_DIR}/.firstboot" ]; then - echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE" + log "DAppNode installed" dappnode_core_start print_vpn_access_credentials fi @@ -1102,7 +1175,7 @@ main() { fi if $IS_MACOS; then - echo "DAppNode installed" 2>&1 | tee -a "$LOGFILE" + log "DAppNode installed" dappnode_core_start print_vpn_access_credentials fi From 548fd516d91adb1954b13cccec7fed992ca1abb3 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Wed, 18 Mar 2026 08:06:41 +0100 Subject: [PATCH 07/19] Update Debian ISO version to 13.4.0 in generate_dappnode_iso_debian.sh (#699) --- iso/scripts/generate_dappnode_iso_debian.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iso/scripts/generate_dappnode_iso_debian.sh b/iso/scripts/generate_dappnode_iso_debian.sh index 201e0082..64fb0a05 100755 --- a/iso/scripts/generate_dappnode_iso_debian.sh +++ b/iso/scripts/generate_dappnode_iso_debian.sh @@ -5,11 +5,11 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh -# Source = https://cdimage.debian.org/mirror/cdimage/archive/12.11.0/amd64/iso-cd/debian-12.11.0-amd64-netinst.iso -BASE_ISO_NAME="debian-12.11.0-amd64-netinst.iso" +# Source = https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.4.0-amd64-netinst.iso +BASE_ISO_NAME="debian-13.4.0-amd64-netinst.iso" BASE_ISO_PATH="/images/${BASE_ISO_NAME}" -BASE_ISO_URL="https://cdimage.debian.org/mirror/cdimage/archive/12.11.0/amd64/iso-cd/${BASE_ISO_NAME}" -BASE_ISO_SHASUM="30ca12a15cae6a1033e03ad59eb7f66a6d5a258dcf27acd115c2bd42d22640e8 ${BASE_ISO_PATH}" +BASE_ISO_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/${BASE_ISO_NAME}" +BASE_ISO_SHASUM="0b813535dd76f2ea96eff908c65e8521512c92a0631fd41c95756ffd7d4896dc ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" DAPPNODE_ISO_PATH="/images/${DAPPNODE_ISO_NAME}" From ef5338ef6ecbdc5d07080ef96ce5e13fa4987018 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Wed, 18 Mar 2026 08:06:49 +0100 Subject: [PATCH 08/19] Update Ubuntu base ISO to version 24.04.4 and correct SHA256 checksum (#698) --- iso/scripts/generate_dappnode_iso_ubuntu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iso/scripts/generate_dappnode_iso_ubuntu.sh b/iso/scripts/generate_dappnode_iso_ubuntu.sh index c1c1a270..50a96933 100755 --- a/iso/scripts/generate_dappnode_iso_ubuntu.sh +++ b/iso/scripts/generate_dappnode_iso_ubuntu.sh @@ -5,10 +5,10 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh -BASE_ISO_NAME=ubuntu-24.04.3-live-server-amd64.iso +BASE_ISO_NAME=ubuntu-24.04.4-live-server-amd64.iso BASE_ISO_PATH="/images/${BASE_ISO_NAME}" BASE_ISO_URL="https://releases.ubuntu.com/24.04/${BASE_ISO_NAME}" -BASE_ISO_SHASUM="c3514bf0056180d09376462a7a1b4f213c1d6e8ea67fae5c25099c6fd3d8274b ${BASE_ISO_PATH}" +BASE_ISO_SHASUM="e907d92eeec9df64163a7e454cbc8d7755e8ddc7ed42f99dbc80c40f1a138433 ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" DAPPNODE_ISO_PATH="/images/${DAPPNODE_ISO_NAME}" From e74b6c5e5782d3dcec3245e1ad88ef2dd76f7343 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:07:52 +0100 Subject: [PATCH 09/19] Enable use of mirror in preseed configuration (#703) --- iso/preseeds/preseed_unattended.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iso/preseeds/preseed_unattended.cfg b/iso/preseeds/preseed_unattended.cfg index be31dba6..cf7b58d4 100644 --- a/iso/preseeds/preseed_unattended.cfg +++ b/iso/preseeds/preseed_unattended.cfg @@ -57,7 +57,7 @@ d-i grub-installer/bootdev string default ### Package selection tasksel tasksel/first multiselect standard d-i pkgsel/include string openssh-server vim sudo build-essential linux-headers-$(uname -r) iw iwd wpasupplicant intel-microcode iucode-tool firmware-misc-nonfree firmware-iwlwifi avahi-utils iptables -d-i apt-setup/use_mirror boolean false +d-i apt-setup/use_mirror boolean true d-i mirror/country string manual d-i mirror/http/hostname string deb.debian.org d-i mirror/http/directory string /debian From 36652dbd0b362c95c80453a09f14b7419318fde2 Mon Sep 17 00:00:00 2001 From: hcastc00 Date: Wed, 6 May 2026 15:59:55 +0200 Subject: [PATCH 10/19] fix: defer --update cleanup until after preflight checks pass --- scripts/dappnode_install.sh | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/dappnode_install.sh b/scripts/dappnode_install.sh index 0379827a..13713c21 100755 --- a/scripts/dappnode_install.sh +++ b/scripts/dappnode_install.sh @@ -527,16 +527,14 @@ patch_dappmanager_compose_for_macos() { } bootstrap_filesystem() { - # Clean if update + # Clean if update — only the logfile and profile are removed here. + # Removing the profile early forces ensure_profile_loaded to re-download + # the latest one (so resolved package versions match the new release). + # Composes/manifests/archives are removed later by clean_for_update, + # AFTER preflight passes — see comment in main(). if [[ "${UPDATE}" == "true" ]]; then - log "Cleaning for update..." rm -f "${LOGFILE}" || true - rm -f "${DAPPNODE_CORE_DIR}"/docker-compose-*.yml || true - rm -f "${DAPPNODE_CORE_DIR}"/dappnode_package-*.json || true - rm -f "${DAPPNODE_CORE_DIR}"/*.tar.xz || true - rm -f "${DAPPNODE_CORE_DIR}"/*.txz || true rm -f "${DAPPNODE_CORE_DIR}/.dappnode_profile" || true - rm -f "${CONTENT_HASH_FILE}" || true fi # Create necessary directories @@ -551,6 +549,22 @@ bootstrap_filesystem() { touch "${LOGFILE}" || true } +# Destructive: remove on-disk artifacts from the previous install so fresh +# downloads take their place. Must only run AFTER preflight checks have passed — +# otherwise a failing preflight (e.g. port conflict) leaves the host with no +# compose files on disk while running containers continue to hold the ports. +clean_for_update() { + if [[ "${UPDATE}" != "true" ]]; then + return 0 + fi + log "Cleaning for update..." + rm -f "${DAPPNODE_CORE_DIR}"/docker-compose-*.yml || true + rm -f "${DAPPNODE_CORE_DIR}"/dappnode_package-*.json || true + rm -f "${DAPPNODE_CORE_DIR}"/*.tar.xz || true + rm -f "${DAPPNODE_CORE_DIR}"/*.txz || true + rm -f "${CONTENT_HASH_FILE}" || true +} + # Generic helper: returns 0 if a process is bound to the given port, 1 if not. # Usage: is_port_listening [tcp|udp] # tcp (default): matches TCP sockets in LISTEN state @@ -1107,6 +1121,10 @@ main() { configure_static_ip ensure_profile_loaded resolve_packages + # Destructive cleanup runs only after preflight (resolve_packages -> check_vpn_ports_conflict) + # has passed; otherwise a failing port check would wipe the on-disk composes while the + # running containers still hold the ports, leaving the node un-restartable. + clean_for_update echo "" 2>&1 | tee -a "$LOGFILE" log "##############################################" From 877fbe818cfef2c3c605a603962f5d8cac5925ea Mon Sep 17 00:00:00 2001 From: hcastc00 Date: Wed, 6 May 2026 16:42:34 +0200 Subject: [PATCH 11/19] fix: enhance VPN port conflict checks to allow updates on running containers --- scripts/dappnode_install.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/dappnode_install.sh b/scripts/dappnode_install.sh index 13713c21..49ecf3f2 100755 --- a/scripts/dappnode_install.sh +++ b/scripts/dappnode_install.sh @@ -605,6 +605,8 @@ check_https_ports_conflict() { # Check that ports required by VPN/Wireguard are not already in use by another process. # Must be called after PKGS is populated. Exits with a helpful error on conflict. +# Ports held by our own dappnode core VPN/Wireguard containers are not conflicts — +# the upcoming compose-up will replace them. check_vpn_ports_conflict() { if ! command -v lsof >/dev/null 2>&1; then return # cannot check; proceed and let the container report a bind error @@ -615,11 +617,16 @@ check_vpn_ports_conflict() { case "$pkg" in WIREGUARD) if is_port_listening 51820 udp; then - error "Port 51820/UDP is already in use on this host." - error "This port is required by the Wireguard package and must be free before installing." - error "Free up port 51820 and re-run the installer, or — if you do not need VPN" - error "connectivity — consider using --minimal instead (advanced users only)." - exit 1 + # Port 51820 is in use; check if it's our own Wireguard container + if docker ps --format '{{.Names}}' 2>/dev/null | grep -qE "^DAppNodeCore-.*wireguard.*\.dnp\.dappnode\.eth$"; then + log "Port 51820/UDP is held by the existing DAppNode Wireguard container; it will be replaced." + else + error "Port 51820/UDP is already in use on this host." + error "This port is required by the Wireguard package and must be free before installing." + error "Free up port 51820 and re-run the installer, or — if you do not need VPN" + error "connectivity — consider using --minimal instead (advanced users only)." + exit 1 + fi fi ;; VPN) @@ -627,11 +634,16 @@ check_vpn_ports_conflict() { is_port_listening 1194 udp && vpn_blocked+=(1194/UDP) is_port_listening 8092 tcp && vpn_blocked+=(8092/TCP) if [[ ${#vpn_blocked[@]} -gt 0 ]]; then - error "Port(s) ${vpn_blocked[*]} are already in use on this host." - error "These ports are required by the OpenVPN package and must be free before installing." - error "Free up the port(s) and re-run the installer, or — if you do not need VPN" - error "connectivity — consider using --minimal instead (advanced users only)." - exit 1 + # Port(s) in use; check if held by our own OpenVPN container + if docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^DAppNodeCore-vpn.dnp.dappnode.eth$"; then + log "Port(s) ${vpn_blocked[*]} are held by the existing DAppNode VPN container; it will be replaced." + else + error "Port(s) ${vpn_blocked[*]} are already in use on this host." + error "These ports are required by the OpenVPN package and must be free before installing." + error "Free up the port(s) and re-run the installer, or — if you do not need VPN" + error "connectivity — consider using --minimal instead (advanced users only)." + exit 1 + fi fi ;; esac From 4e156d71804a5abf158f7a53fc3029489994a84a Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Thu, 28 May 2026 16:02:36 +0200 Subject: [PATCH 12/19] Add daily workflow to auto-update Ubuntu and Debian base ISOs --- .github/workflows/update-base-isos.yml | 157 +++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 .github/workflows/update-base-isos.yml diff --git a/.github/workflows/update-base-isos.yml b/.github/workflows/update-base-isos.yml new file mode 100644 index 00000000..eab37e14 --- /dev/null +++ b/.github/workflows/update-base-isos.yml @@ -0,0 +1,157 @@ +name: Update Base ISOs + +on: + schedule: + # Run daily at 08:00 UTC + - cron: "0 8 * * *" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + update-ubuntu-iso: + name: Check for Ubuntu ISO updates + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v6 + + - name: Check for new Ubuntu ISO version + id: ubuntu + run: | + SCRIPT="iso/scripts/generate_dappnode_iso_ubuntu.sh" + + # Get current version from script + CURRENT_ISO=$(grep -oP 'BASE_ISO_NAME=\K.*' "$SCRIPT") + echo "Current Ubuntu ISO: $CURRENT_ISO" + + # Fetch the SHA256SUMS file from Ubuntu releases + SHA256SUMS=$(curl -fsSL "https://releases.ubuntu.com/24.04/SHA256SUMS") + + # Find the latest live-server ISO entry + LATEST_LINE=$(echo "$SHA256SUMS" | grep 'live-server-amd64.iso' | head -1) + if [ -z "$LATEST_LINE" ]; then + echo "Could not find live-server ISO in SHA256SUMS" + exit 0 + fi + + LATEST_SHA=$(echo "$LATEST_LINE" | awk '{print $1}') + LATEST_ISO=$(echo "$LATEST_LINE" | awk '{print $2}' | sed 's|^\*||') + # Remove any leading path (e.g., "./" or directory prefix) + LATEST_ISO=$(basename "$LATEST_ISO") + + echo "Latest Ubuntu ISO: $LATEST_ISO (sha256: $LATEST_SHA)" + + if [ "$CURRENT_ISO" = "$LATEST_ISO" ]; then + echo "Ubuntu ISO is already up to date." + echo "updated=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + # Update the script + CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^"]*' "$SCRIPT" | awk '{print $1}') + sed -i "s|${CURRENT_ISO}|${LATEST_ISO}|g" "$SCRIPT" + sed -i "s|${CURRENT_SHA}|${LATEST_SHA}|" "$SCRIPT" + + echo "updated=true" >> "$GITHUB_OUTPUT" + echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" + echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" + + - name: Create Pull Request for Ubuntu ISO update + if: steps.ubuntu.outputs.updated == 'true' + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}" + branch: auto/update-ubuntu-iso + delete-branch: true + title: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}" + body: | + Automated update of the Ubuntu base ISO. + + - **Previous**: `${{ steps.ubuntu.outputs.current_iso }}` + - **New**: `${{ steps.ubuntu.outputs.latest_iso }}` + + This PR was created automatically by the `update-base-isos` workflow. + labels: automated + + update-debian-iso: + name: Check for Debian ISO updates + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v6 + + - name: Check for new Debian ISO version + id: debian + run: | + SCRIPT="iso/scripts/generate_dappnode_iso_debian.sh" + + # Get current version from script + CURRENT_ISO=$(grep -oP 'BASE_ISO_NAME="\K[^"]*' "$SCRIPT") + echo "Current Debian ISO: $CURRENT_ISO" + + # Fetch the SHA256SUMS file from Debian current release + SHA256SUMS=$(curl -fsSL "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS") + + # Find the latest netinst ISO entry + LATEST_LINE=$(echo "$SHA256SUMS" | grep 'amd64-netinst.iso' | head -1) + if [ -z "$LATEST_LINE" ]; then + echo "Could not find netinst ISO in SHA256SUMS" + exit 0 + fi + + LATEST_SHA=$(echo "$LATEST_LINE" | awk '{print $1}') + LATEST_ISO=$(echo "$LATEST_LINE" | awk '{print $2}' | sed 's|^\*||') + LATEST_ISO=$(basename "$LATEST_ISO") + + echo "Latest Debian ISO: $LATEST_ISO (sha256: $LATEST_SHA)" + + if [ "$CURRENT_ISO" = "$LATEST_ISO" ]; then + echo "Debian ISO is already up to date." + echo "updated=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + # Extract version numbers for URL update + CURRENT_VERSION=$(echo "$CURRENT_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') + LATEST_VERSION=$(echo "$LATEST_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') + + # Update the script + CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^ ]*' "$SCRIPT") + sed -i "s|${CURRENT_ISO}|${LATEST_ISO}|g" "$SCRIPT" + sed -i "s|${CURRENT_SHA}|${LATEST_SHA}|" "$SCRIPT" + + # Update the source comment and URL if the major version changed + CURRENT_MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) + LATEST_MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1) + + if [ "$CURRENT_MAJOR" != "$LATEST_MAJOR" ]; then + # If major version changes, update any archive URL to current + sed -i "s|cdimage.debian.org/mirror/cdimage/archive/${CURRENT_VERSION}|cdimage.debian.org/debian-cd/current|" "$SCRIPT" + fi + + # Update version in the source comment + sed -i "s|${CURRENT_VERSION}|${LATEST_VERSION}|g" "$SCRIPT" + + echo "updated=true" >> "$GITHUB_OUTPUT" + echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" + echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" + + - name: Create Pull Request for Debian ISO update + if: steps.debian.outputs.updated == 'true' + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}" + branch: auto/update-debian-iso + delete-branch: true + title: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}" + body: | + Automated update of the Debian base ISO. + + - **Previous**: `${{ steps.debian.outputs.current_iso }}` + - **New**: `${{ steps.debian.outputs.latest_iso }}` + + This PR was created automatically by the `update-base-isos` workflow. + labels: automated From faa8a8f6584edb4ee76fb242d07f7ca712d2e775 Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Thu, 28 May 2026 16:08:43 +0200 Subject: [PATCH 13/19] Add stale PR handling and use GitHub App token for ISO update workflow --- .github/workflows/update-base-isos.yml | 38 +++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-base-isos.yml b/.github/workflows/update-base-isos.yml index eab37e14..5b260ee5 100644 --- a/.github/workflows/update-base-isos.yml +++ b/.github/workflows/update-base-isos.yml @@ -6,15 +6,17 @@ on: - cron: "0 8 * * *" workflow_dispatch: -permissions: - contents: write - pull-requests: write - jobs: update-ubuntu-iso: name: Check for Ubuntu ISO updates runs-on: ubuntu-latest steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.TROPI_APP_ID }} + private-key: ${{ secrets.TROPI_APP_PRIVATE_KEY }} + - name: Checkout Code uses: actions/checkout@v6 @@ -59,10 +61,21 @@ jobs: echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" + - name: Close outdated Ubuntu ISO PR + if: steps.ubuntu.outputs.updated == 'true' + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + EXISTING_PR=$(gh pr list --head auto/update-ubuntu-iso --state open --json number --jq '.[0].number') + if [ -n "$EXISTING_PR" ]; then + gh pr close "$EXISTING_PR" --comment "Superseded by a newer Ubuntu ISO version (${{ steps.ubuntu.outputs.latest_iso }})." --delete-branch + fi + - name: Create Pull Request for Ubuntu ISO update if: steps.ubuntu.outputs.updated == 'true' uses: peter-evans/create-pull-request@v7 with: + token: ${{ steps.app-token.outputs.token }} commit-message: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}" branch: auto/update-ubuntu-iso delete-branch: true @@ -80,6 +93,12 @@ jobs: name: Check for Debian ISO updates runs-on: ubuntu-latest steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.TROPI_APP_ID }} + private-key: ${{ secrets.TROPI_APP_PRIVATE_KEY }} + - name: Checkout Code uses: actions/checkout@v6 @@ -139,10 +158,21 @@ jobs: echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" + - name: Close outdated Debian ISO PR + if: steps.debian.outputs.updated == 'true' + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + EXISTING_PR=$(gh pr list --head auto/update-debian-iso --state open --json number --jq '.[0].number') + if [ -n "$EXISTING_PR" ]; then + gh pr close "$EXISTING_PR" --comment "Superseded by a newer Debian ISO version (${{ steps.debian.outputs.latest_iso }})." --delete-branch + fi + - name: Create Pull Request for Debian ISO update if: steps.debian.outputs.updated == 'true' uses: peter-evans/create-pull-request@v7 with: + token: ${{ steps.app-token.outputs.token }} commit-message: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}" branch: auto/update-debian-iso delete-branch: true From 6ab2c4b4fc481b46fba5b8feb1cda6f869f07ccb Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Thu, 28 May 2026 14:10:02 +0000 Subject: [PATCH 14/19] Update Ubuntu base ISO to ubuntu-24.04.3-live-server-amd64.iso --- iso/scripts/generate_dappnode_iso_ubuntu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iso/scripts/generate_dappnode_iso_ubuntu.sh b/iso/scripts/generate_dappnode_iso_ubuntu.sh index 50a96933..c1c1a270 100755 --- a/iso/scripts/generate_dappnode_iso_ubuntu.sh +++ b/iso/scripts/generate_dappnode_iso_ubuntu.sh @@ -5,10 +5,10 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh -BASE_ISO_NAME=ubuntu-24.04.4-live-server-amd64.iso +BASE_ISO_NAME=ubuntu-24.04.3-live-server-amd64.iso BASE_ISO_PATH="/images/${BASE_ISO_NAME}" BASE_ISO_URL="https://releases.ubuntu.com/24.04/${BASE_ISO_NAME}" -BASE_ISO_SHASUM="e907d92eeec9df64163a7e454cbc8d7755e8ddc7ed42f99dbc80c40f1a138433 ${BASE_ISO_PATH}" +BASE_ISO_SHASUM="c3514bf0056180d09376462a7a1b4f213c1d6e8ea67fae5c25099c6fd3d8274b ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" DAPPNODE_ISO_PATH="/images/${DAPPNODE_ISO_NAME}" From 02fd181383bfa2403ff39898e95fb0a1c9c42c9f Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Thu, 28 May 2026 14:10:06 +0000 Subject: [PATCH 15/19] Update Debian base ISO to debian-13.5.0-amd64-netinst.iso --- iso/scripts/generate_dappnode_iso_debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iso/scripts/generate_dappnode_iso_debian.sh b/iso/scripts/generate_dappnode_iso_debian.sh index 64fb0a05..75e940ee 100755 --- a/iso/scripts/generate_dappnode_iso_debian.sh +++ b/iso/scripts/generate_dappnode_iso_debian.sh @@ -5,11 +5,11 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh -# Source = https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.4.0-amd64-netinst.iso -BASE_ISO_NAME="debian-13.4.0-amd64-netinst.iso" +# Source = https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.5.0-amd64-netinst.iso +BASE_ISO_NAME="debian-13.5.0-amd64-netinst.iso" BASE_ISO_PATH="/images/${BASE_ISO_NAME}" BASE_ISO_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/${BASE_ISO_NAME}" -BASE_ISO_SHASUM="0b813535dd76f2ea96eff908c65e8521512c92a0631fd41c95756ffd7d4896dc ${BASE_ISO_PATH}" +BASE_ISO_SHASUM="95838884f5ea6c82421dfe6baaa5a639dbbe6756c1e380f9fe7a7cb0c1949d2a ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" DAPPNODE_ISO_PATH="/images/${DAPPNODE_ISO_NAME}" From 08f51b36b32182d7bd3ab19313710d30a407c8c7 Mon Sep 17 00:00:00 2001 From: hcastc00 Date: Thu, 11 Jun 2026 16:04:05 +0200 Subject: [PATCH 16/19] fix: generate release changelog from built ISO artifacts --- .github/workflows/release.yml | 62 ++++++++++++++++++++++++++++++++--- README.md | 2 +- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6cd00b7..74ad8bf8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -238,10 +238,64 @@ jobs: mv artifacts/dappnode_profile/* . - name: Write release content run: | - SHASUM_DEBIAN_ATTENDED=$(cat SHASUM_DEBIAN_ATTENDED.txt) - SHASUM_DEBIAN_UNATTENDED=$(cat SHASUM_DEBIAN_UNATTENDED.txt) - SHASUM_UBUNTU_UNATTENDED=$(cat SHASUM_UBUNTU_UNATTENDED.txt) - echo -en "# Versions\n| Package | Version |\n|---|---|\nbind.dnp.dappnode.eth|${{ needs.set-versions.outputs.bind }}|\n|ipfs.dnp.dappnode.eth|${{ needs.set-versions.outputs.ipfs }}|\n|vpn.dnp.dappnode.eth |${{ needs.set-versions.outputs.vpn }}|\n|dappmanager.dnp.dappnode.eth|${{ needs.set-versions.outputs.dappmanager }}|\n|wifi.dnp.dappnode.eth|${{ needs.set-versions.outputs.wifi }}|\n|https.dnp.dappnode.eth|${{ needs.set-versions.outputs.https }}|\n|wireguard.dnp.dappnode.eth|${{ needs.set-versions.outputs.wireguard }}|\n|notifications.dnp.dappnode.eth|${{ needs.set-versions.outputs.notifications }}|\n|premium.dnp.dappnode.eth|${{ needs.set-versions.outputs.premium }}|\n# Changes\nChanges implemented in release ${{ needs.set-versions.outputs.core }}\n# Debian Attended version\nInstall and customize DAppNode using the attended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64.iso\n$SHASUM_DEBIAN_ATTENDED\n```\n# Debian Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso**\nDo a reboot right after the installation\n:warning: **Warning**: This ISO will install Dappnode automatically, deleting all existing partitions on the disk\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-debian-bookworm-amd64-unattended.iso\n$SHASUM_DEBIAN_UNATTENDED\n```\n# Ubuntu Unattended version\nInstall DAppNode easily using the unattended ISO: **DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso**\n\n## ISO SHA-256 Checksum\n```\nshasum -a 256 DAppNode-${{ needs.set-versions.outputs.core }}-ubuntu-bookworm-amd64-unattended.iso\n$SHASUM_UBUNTU_UNATTENDED\n```\nUploaded at https://ubuntu.iso.dappnode.io\n# DAppNode for Raspberry Pi 4 64bit\n[Instructions](https://github.com/dappnode/DAppNode/wiki/DAppNodeARM-Installation-Guide)\n\ndefault login data:\n - **__user__**: dappnode\n - **__password__**: dappnodepi" > CHANGELOG.md + DEBIAN_ATTENDED_ISO=$(basename "$(find images/ -type f -name '*-debian-*-attended.iso' -print -quit)") + DEBIAN_UNATTENDED_ISO=$(basename "$(find images/ -type f -name '*-debian-*-unattended.iso' -print -quit)") + UBUNTU_UNATTENDED_ISO=$(basename "$(awk '{print $2}' SHASUM_UBUNTU_UNATTENDED.txt)") + SHASUM_DEBIAN_ATTENDED=$(sed "s#images/##g" SHASUM_DEBIAN_ATTENDED.txt) + SHASUM_DEBIAN_UNATTENDED=$(sed "s#images/##g" SHASUM_DEBIAN_UNATTENDED.txt) + SHASUM_UBUNTU_UNATTENDED=$(sed "s#images/##g" SHASUM_UBUNTU_UNATTENDED.txt) + cat > CHANGELOG.md < Date: Mon, 20 Jul 2026 10:21:59 +0200 Subject: [PATCH 17/19] Simplify base ISO update workflow --- .github/workflows/update-base-isos.yml | 97 +++++++++++++++----------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/.github/workflows/update-base-isos.yml b/.github/workflows/update-base-isos.yml index 5b260ee5..ffc2bba9 100644 --- a/.github/workflows/update-base-isos.yml +++ b/.github/workflows/update-base-isos.yml @@ -25,18 +25,19 @@ jobs: run: | SCRIPT="iso/scripts/generate_dappnode_iso_ubuntu.sh" - # Get current version from script + # Get the current ISO and checksum from the script CURRENT_ISO=$(grep -oP 'BASE_ISO_NAME=\K.*' "$SCRIPT") + CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^" ]*' "$SCRIPT") echo "Current Ubuntu ISO: $CURRENT_ISO" # Fetch the SHA256SUMS file from Ubuntu releases SHA256SUMS=$(curl -fsSL "https://releases.ubuntu.com/24.04/SHA256SUMS") # Find the latest live-server ISO entry - LATEST_LINE=$(echo "$SHA256SUMS" | grep 'live-server-amd64.iso' | head -1) + LATEST_LINE=$(echo "$SHA256SUMS" | grep 'live-server-amd64.iso' | head -1 || true) if [ -z "$LATEST_LINE" ]; then echo "Could not find live-server ISO in SHA256SUMS" - exit 0 + exit 1 fi LATEST_SHA=$(echo "$LATEST_LINE" | awk '{print $1}') @@ -44,16 +45,22 @@ jobs: # Remove any leading path (e.g., "./" or directory prefix) LATEST_ISO=$(basename "$LATEST_ISO") + if [[ ! "$LATEST_SHA" =~ ^[0-9a-f]{64}$ ]] || + [[ ! "$LATEST_ISO" =~ ^ubuntu-24\.04(\.[0-9]+)?-live-server-amd64\.iso$ ]]; then + echo "Ubuntu SHA256SUMS contains an invalid ISO entry" + exit 1 + fi + echo "Latest Ubuntu ISO: $LATEST_ISO (sha256: $LATEST_SHA)" - if [ "$CURRENT_ISO" = "$LATEST_ISO" ]; then + # Nothing to do only when both the filename and checksum match + if [ "$CURRENT_ISO" = "$LATEST_ISO" ] && [ "$CURRENT_SHA" = "$LATEST_SHA" ]; then echo "Ubuntu ISO is already up to date." echo "updated=false" >> "$GITHUB_OUTPUT" exit 0 fi # Update the script - CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^"]*' "$SCRIPT" | awk '{print $1}') sed -i "s|${CURRENT_ISO}|${LATEST_ISO}|g" "$SCRIPT" sed -i "s|${CURRENT_SHA}|${LATEST_SHA}|" "$SCRIPT" @@ -61,24 +68,14 @@ jobs: echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" - - name: Close outdated Ubuntu ISO PR - if: steps.ubuntu.outputs.updated == 'true' - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - EXISTING_PR=$(gh pr list --head auto/update-ubuntu-iso --state open --json number --jq '.[0].number') - if [ -n "$EXISTING_PR" ]; then - gh pr close "$EXISTING_PR" --comment "Superseded by a newer Ubuntu ISO version (${{ steps.ubuntu.outputs.latest_iso }})." --delete-branch - fi - - - name: Create Pull Request for Ubuntu ISO update + - name: Create or update Pull Request for Ubuntu ISO if: steps.ubuntu.outputs.updated == 'true' + id: ubuntu-pr uses: peter-evans/create-pull-request@v7 with: token: ${{ steps.app-token.outputs.token }} commit-message: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}" branch: auto/update-ubuntu-iso - delete-branch: true title: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}" body: | Automated update of the Ubuntu base ISO. @@ -89,6 +86,19 @@ jobs: This PR was created automatically by the `update-base-isos` workflow. labels: automated + - name: Sync PR title and body on subsequent runs + if: steps.ubuntu-pr.outputs.pull-request-operation == 'updated' + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + PR_NUMBER: ${{ steps.ubuntu-pr.outputs.pull-request-number }} + CURRENT_ISO: ${{ steps.ubuntu.outputs.current_iso }} + LATEST_ISO: ${{ steps.ubuntu.outputs.latest_iso }} + run: | + BODY=$(printf 'Automated update of the Ubuntu base ISO.\n\n- **Previous**: `%s`\n- **New**: `%s`\n\nThis PR was created automatically by the `update-base-isos` workflow.' "$CURRENT_ISO" "$LATEST_ISO") + gh pr edit "$PR_NUMBER" \ + --title "Update Ubuntu base ISO to $LATEST_ISO" \ + --body "$BODY" + update-debian-iso: name: Check for Debian ISO updates runs-on: ubuntu-latest @@ -107,27 +117,35 @@ jobs: run: | SCRIPT="iso/scripts/generate_dappnode_iso_debian.sh" - # Get current version from script + # Get the current ISO and checksum from the script CURRENT_ISO=$(grep -oP 'BASE_ISO_NAME="\K[^"]*' "$SCRIPT") + CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^" ]*' "$SCRIPT") echo "Current Debian ISO: $CURRENT_ISO" # Fetch the SHA256SUMS file from Debian current release SHA256SUMS=$(curl -fsSL "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS") # Find the latest netinst ISO entry - LATEST_LINE=$(echo "$SHA256SUMS" | grep 'amd64-netinst.iso' | head -1) + LATEST_LINE=$(echo "$SHA256SUMS" | grep 'amd64-netinst.iso' | head -1 || true) if [ -z "$LATEST_LINE" ]; then echo "Could not find netinst ISO in SHA256SUMS" - exit 0 + exit 1 fi LATEST_SHA=$(echo "$LATEST_LINE" | awk '{print $1}') LATEST_ISO=$(echo "$LATEST_LINE" | awk '{print $2}' | sed 's|^\*||') LATEST_ISO=$(basename "$LATEST_ISO") + if [[ ! "$LATEST_SHA" =~ ^[0-9a-f]{64}$ ]] || + [[ ! "$LATEST_ISO" =~ ^debian-[0-9]+\.[0-9]+\.[0-9]+-amd64-netinst\.iso$ ]]; then + echo "Debian SHA256SUMS contains an invalid ISO entry" + exit 1 + fi + echo "Latest Debian ISO: $LATEST_ISO (sha256: $LATEST_SHA)" - if [ "$CURRENT_ISO" = "$LATEST_ISO" ]; then + # Nothing to do only when both the filename and checksum match + if [ "$CURRENT_ISO" = "$LATEST_ISO" ] && [ "$CURRENT_SHA" = "$LATEST_SHA" ]; then echo "Debian ISO is already up to date." echo "updated=false" >> "$GITHUB_OUTPUT" exit 0 @@ -136,46 +154,30 @@ jobs: # Extract version numbers for URL update CURRENT_VERSION=$(echo "$CURRENT_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') LATEST_VERSION=$(echo "$LATEST_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') + CURRENT_MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) + LATEST_MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1) # Update the script - CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^ ]*' "$SCRIPT") sed -i "s|${CURRENT_ISO}|${LATEST_ISO}|g" "$SCRIPT" sed -i "s|${CURRENT_SHA}|${LATEST_SHA}|" "$SCRIPT" - - # Update the source comment and URL if the major version changed - CURRENT_MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) - LATEST_MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1) - if [ "$CURRENT_MAJOR" != "$LATEST_MAJOR" ]; then # If major version changes, update any archive URL to current sed -i "s|cdimage.debian.org/mirror/cdimage/archive/${CURRENT_VERSION}|cdimage.debian.org/debian-cd/current|" "$SCRIPT" fi - - # Update version in the source comment sed -i "s|${CURRENT_VERSION}|${LATEST_VERSION}|g" "$SCRIPT" echo "updated=true" >> "$GITHUB_OUTPUT" echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT" - - name: Close outdated Debian ISO PR - if: steps.debian.outputs.updated == 'true' - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - EXISTING_PR=$(gh pr list --head auto/update-debian-iso --state open --json number --jq '.[0].number') - if [ -n "$EXISTING_PR" ]; then - gh pr close "$EXISTING_PR" --comment "Superseded by a newer Debian ISO version (${{ steps.debian.outputs.latest_iso }})." --delete-branch - fi - - - name: Create Pull Request for Debian ISO update + - name: Create or update Pull Request for Debian ISO if: steps.debian.outputs.updated == 'true' + id: debian-pr uses: peter-evans/create-pull-request@v7 with: token: ${{ steps.app-token.outputs.token }} commit-message: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}" branch: auto/update-debian-iso - delete-branch: true title: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}" body: | Automated update of the Debian base ISO. @@ -185,3 +187,16 @@ jobs: This PR was created automatically by the `update-base-isos` workflow. labels: automated + + - name: Sync PR title and body on subsequent runs + if: steps.debian-pr.outputs.pull-request-operation == 'updated' + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + PR_NUMBER: ${{ steps.debian-pr.outputs.pull-request-number }} + CURRENT_ISO: ${{ steps.debian.outputs.current_iso }} + LATEST_ISO: ${{ steps.debian.outputs.latest_iso }} + run: | + BODY=$(printf 'Automated update of the Debian base ISO.\n\n- **Previous**: `%s`\n- **New**: `%s`\n\nThis PR was created automatically by the `update-base-isos` workflow.' "$CURRENT_ISO" "$LATEST_ISO") + gh pr edit "$PR_NUMBER" \ + --title "Update Debian base ISO to $LATEST_ISO" \ + --body "$BODY" From 0848c1bed80c40dd68e774bd92f3dde8147ef2b7 Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:00:10 +0200 Subject: [PATCH 18/19] Make ISO updates version independent --- .github/workflows/update-base-isos.yml | 37 +++++++++++---------- iso/scripts/generate_dappnode_iso_debian.sh | 5 +-- iso/scripts/generate_dappnode_iso_ubuntu.sh | 5 ++- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/workflows/update-base-isos.yml b/.github/workflows/update-base-isos.yml index ffc2bba9..8d355fa0 100644 --- a/.github/workflows/update-base-isos.yml +++ b/.github/workflows/update-base-isos.yml @@ -30,11 +30,21 @@ jobs: CURRENT_SHA=$(grep -oP 'BASE_ISO_SHASUM="\K[^" ]*' "$SCRIPT") echo "Current Ubuntu ISO: $CURRENT_ISO" - # Fetch the SHA256SUMS file from Ubuntu releases - SHA256SUMS=$(curl -fsSL "https://releases.ubuntu.com/24.04/SHA256SUMS") + # Discover the newest Ubuntu LTS series, then fetch its checksums + LATEST_LTS_VERSION=$(curl -fsSL "https://changelogs.ubuntu.com/meta-release-lts" | + awk '/^Version:/ { version=$2 } END { print version }') + LATEST_LTS_SERIES=$(echo "$LATEST_LTS_VERSION" | cut -d. -f1,2) + if [[ ! "$LATEST_LTS_SERIES" =~ ^[0-9]+\.[0-9]+$ ]]; then + echo "Could not determine the latest Ubuntu LTS series" + exit 1 + fi + + SHA256SUMS=$(curl -fsSL "https://releases.ubuntu.com/${LATEST_LTS_SERIES}/SHA256SUMS") - # Find the latest live-server ISO entry - LATEST_LINE=$(echo "$SHA256SUMS" | grep 'live-server-amd64.iso' | head -1 || true) + # Find the highest live-server point release in that LTS series + LATEST_LINE=$(echo "$SHA256SUMS" | + grep -E "[[:space:]]\\*?ubuntu-${LATEST_LTS_SERIES//./\\.}(\\.[0-9]+)?-live-server-amd64\\.iso$" | + sort -V -k2 | tail -1 || true) if [ -z "$LATEST_LINE" ]; then echo "Could not find live-server ISO in SHA256SUMS" exit 1 @@ -46,7 +56,7 @@ jobs: LATEST_ISO=$(basename "$LATEST_ISO") if [[ ! "$LATEST_SHA" =~ ^[0-9a-f]{64}$ ]] || - [[ ! "$LATEST_ISO" =~ ^ubuntu-24\.04(\.[0-9]+)?-live-server-amd64\.iso$ ]]; then + [[ ! "$LATEST_ISO" =~ ^ubuntu-[0-9]+\.[0-9]+(\.[0-9]+)?-live-server-amd64\.iso$ ]]; then echo "Ubuntu SHA256SUMS contains an invalid ISO entry" exit 1 fi @@ -125,8 +135,10 @@ jobs: # Fetch the SHA256SUMS file from Debian current release SHA256SUMS=$(curl -fsSL "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS") - # Find the latest netinst ISO entry - LATEST_LINE=$(echo "$SHA256SUMS" | grep 'amd64-netinst.iso' | head -1 || true) + # Find the standard netinst ISO, excluding the Edu and Mac variants + LATEST_LINE=$(echo "$SHA256SUMS" | + grep -E '[[:space:]]\*?debian-[0-9]+\.[0-9]+\.[0-9]+-amd64-netinst\.iso$' | + sort -V -k2 | tail -1 || true) if [ -z "$LATEST_LINE" ]; then echo "Could not find netinst ISO in SHA256SUMS" exit 1 @@ -151,20 +163,9 @@ jobs: exit 0 fi - # Extract version numbers for URL update - CURRENT_VERSION=$(echo "$CURRENT_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') - LATEST_VERSION=$(echo "$LATEST_ISO" | grep -oP 'debian-\K[0-9]+\.[0-9]+\.[0-9]+') - CURRENT_MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) - LATEST_MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1) - # Update the script sed -i "s|${CURRENT_ISO}|${LATEST_ISO}|g" "$SCRIPT" sed -i "s|${CURRENT_SHA}|${LATEST_SHA}|" "$SCRIPT" - if [ "$CURRENT_MAJOR" != "$LATEST_MAJOR" ]; then - # If major version changes, update any archive URL to current - sed -i "s|cdimage.debian.org/mirror/cdimage/archive/${CURRENT_VERSION}|cdimage.debian.org/debian-cd/current|" "$SCRIPT" - fi - sed -i "s|${CURRENT_VERSION}|${LATEST_VERSION}|g" "$SCRIPT" echo "updated=true" >> "$GITHUB_OUTPUT" echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT" diff --git a/iso/scripts/generate_dappnode_iso_debian.sh b/iso/scripts/generate_dappnode_iso_debian.sh index 75e940ee..4ec4a93d 100755 --- a/iso/scripts/generate_dappnode_iso_debian.sh +++ b/iso/scripts/generate_dappnode_iso_debian.sh @@ -5,10 +5,11 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh -# Source = https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.5.0-amd64-netinst.iso BASE_ISO_NAME="debian-13.5.0-amd64-netinst.iso" +BASE_ISO_VERSION="${BASE_ISO_NAME#debian-}" +BASE_ISO_VERSION="${BASE_ISO_VERSION%-amd64-netinst.iso}" BASE_ISO_PATH="/images/${BASE_ISO_NAME}" -BASE_ISO_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/${BASE_ISO_NAME}" +BASE_ISO_URL="https://cdimage.debian.org/mirror/cdimage/archive/${BASE_ISO_VERSION}/amd64/iso-cd/${BASE_ISO_NAME}" BASE_ISO_SHASUM="95838884f5ea6c82421dfe6baaa5a639dbbe6756c1e380f9fe7a7cb0c1949d2a ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" diff --git a/iso/scripts/generate_dappnode_iso_ubuntu.sh b/iso/scripts/generate_dappnode_iso_ubuntu.sh index c1c1a270..efd0f3fa 100755 --- a/iso/scripts/generate_dappnode_iso_ubuntu.sh +++ b/iso/scripts/generate_dappnode_iso_ubuntu.sh @@ -6,8 +6,11 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source ${SCRIPTS_DIR}/common_iso_generation.sh BASE_ISO_NAME=ubuntu-24.04.3-live-server-amd64.iso +BASE_ISO_VERSION="${BASE_ISO_NAME#ubuntu-}" +BASE_ISO_VERSION="${BASE_ISO_VERSION%-live-server-amd64.iso}" +BASE_ISO_SERIES=$(echo "$BASE_ISO_VERSION" | cut -d. -f1,2) BASE_ISO_PATH="/images/${BASE_ISO_NAME}" -BASE_ISO_URL="https://releases.ubuntu.com/24.04/${BASE_ISO_NAME}" +BASE_ISO_URL="https://releases.ubuntu.com/${BASE_ISO_SERIES}/${BASE_ISO_NAME}" BASE_ISO_SHASUM="c3514bf0056180d09376462a7a1b4f213c1d6e8ea67fae5c25099c6fd3d8274b ${BASE_ISO_PATH}" DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}" From 25ce162126bd5236fa95d67ad13a6496c3e3fdc3 Mon Sep 17 00:00:00 2001 From: Marketen Date: Thu, 20 Aug 2026 10:28:03 +0200 Subject: [PATCH 19/19] use trixie --- iso/preseeds/preseed.cfg | 4 ++-- iso/preseeds/preseed_unattended.cfg | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iso/preseeds/preseed.cfg b/iso/preseeds/preseed.cfg index 761f5075..1bd38005 100644 --- a/iso/preseeds/preseed.cfg +++ b/iso/preseeds/preseed.cfg @@ -1,7 +1,7 @@ # Preseed-example: https://www.debian.org/releases/stable/example-preseed.txt # Buster preseed example: https://www.debian.org/releases/buster/example-preseed.txt # Bullseye preseed example: https://www.debian.org/releases/testing/example-preseed.txt -# Bookworm preseed example: https://www.debian.org/releases/bookworm/example-preseed.txt +# Trixie preseed example: https://www.debian.org/releases/trixie/example-preseed.txt ### Network configuration d-i hw-detect/load_firmware boolean true d-i netcfg/choose_interface select auto @@ -25,7 +25,7 @@ d-i mirror/country string manual d-i mirror/http/hostname string deb.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string -d-i apt-setup/local0/repository string http://deb.debian.org/debian/ bookworm main contrib non-free-firmware +d-i apt-setup/local0/repository string http://deb.debian.org/debian/ trixie main contrib non-free-firmware d-i apt-setup/cdrom/set-first boolean false d-i apt-setup/cdrom/set-next boolean false d-i apt-setup/cdrom/set-failed boolean false diff --git a/iso/preseeds/preseed_unattended.cfg b/iso/preseeds/preseed_unattended.cfg index cf7b58d4..8316fd7c 100644 --- a/iso/preseeds/preseed_unattended.cfg +++ b/iso/preseeds/preseed_unattended.cfg @@ -1,7 +1,7 @@ # Preseed-example: https://www.debian.org/releases/stable/example-preseed.txt # Buster preseed example: https://www.debian.org/releases/buster/example-preseed.txt # Bullseye preseed example: https://www.debian.org/releases/testing/example-preseed.txt -# Bookworm preseed example: https://www.debian.org/releases/bookworm/example-preseed.txt +# Trixie preseed example: https://www.debian.org/releases/trixie/example-preseed.txt ### Localization d-i debian-installer/locale string en_US.UTF-8 d-i debian-installer/keymap select us @@ -62,7 +62,7 @@ d-i mirror/country string manual d-i mirror/http/hostname string deb.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string -d-i apt-setup/local0/repository string http://deb.debian.org/debian/ bookworm main contrib non-free-firmware +d-i apt-setup/local0/repository string http://deb.debian.org/debian/ trixie main contrib non-free-firmware d-i apt-setup/cdrom/set-first boolean false d-i apt-setup/cdrom/set-next boolean false d-i apt-setup/cdrom/set-failed boolean false