Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Last active February 2, 2022 08:47
Show Gist options
  • Save mpontillo/6ee4c96d8aed4d0efde66a37aa6d5af9 to your computer and use it in GitHub Desktop.
Save mpontillo/6ee4c96d8aed4d0efde66a37aa6d5af9 to your computer and use it in GitHub Desktop.

Revisions

  1. mpontillo revised this gist Apr 22, 2017. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions test-maas-enlistment.sh
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,13 @@ echo "===== BEGIN PXE CONFIG ====="
    cat "$TMPDIR/pxe-config"
    echo "===== END PXE CONFIG ====="

    GRUB_CFG_URL="tftp://$server/grub/grub.cfg-default-amd64-generic"
    curl -s "$GRUB_CFG_URL" > "$TMPDIR/grub-config"
    echo ""
    echo "===== BEGIN GRUB CONFIG ====="
    cat "$TMPDIR/grub-config"
    echo "===== END GRUB CONFIG ====="

    CONFIG_URL=$(cat "$TMPDIR/pxe-config" \
    | grep ' APPEND.*cloud-config-url' \
    | tr ' ' '\n' \
  2. mpontillo revised this gist Apr 22, 2017. 1 changed file with 30 additions and 3 deletions.
    33 changes: 30 additions & 3 deletions test-maas-enlistment.sh
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@ trap cleanup EXIT

    server=${1:-localhost}

    PXE_URL="tftp://$server/pxelinux.cfg/default-amd64-generic"
    curl -s "$PXE_URL" > "$TMPDIR/pxe-config"
    PXE_CFG_URL="tftp://$server/pxelinux.cfg/default-amd64-generic"
    curl -s "$PXE_CFG_URL" > "$TMPDIR/pxe-config"

    echo ""
    echo "===== BEGIN PXE CONFIG ====="
    @@ -36,4 +36,31 @@ METADATA_URL=$(cat "$TMPDIR/enlist-config" \
    | grep 'metadata_url: ' \
    | awk '{ print $2 }')
    echo ""
    echo "Found metadata URL: $METADATA_URL"
    echo "Found metadata URL: $METADATA_URL"


    LOADERS="
    tftp://$server/pxelinux.0
    tftp://$server/chain.c32
    tftp://$server/ifcpu64.c32
    tftp://$server/ldlinux.c32
    tftp://$server/libcom32.c32
    tftp://$server/libutil.c32
    tftp://$server/bootx64.efi
    tftp://$server/grubx64.efi
    tftp://$server/grubaa64.efi
    tftp://$server/bootppc64.bin
    "

    set -o pipefail
    echo ""
    echo "===== BEGIN BOOT LOADER SHA256 SUMS ====="
    for loader in $LOADERS; do
    loader_sha256=$(curl -sqf "$loader" | sha256sum | awk '{ print $1 }' || touch $TMPDIR/not-found)
    if [ -f $TMPDIR/not-found ]; then
    loader_sha256="[WARNING: file not found]"
    rm $TMPDIR/not-found
    fi
    printf "%40s\n%10s%s\n\n" "$loader" "" "$loader_sha256"
    done
    echo "===== END BOOT LOADER SHA256 SUMS ====="
  3. mpontillo created this gist Apr 21, 2017.
    39 changes: 39 additions & 0 deletions test-maas-enlistment.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/bin/bash -e

    TMPDIR="$(mktemp -d)"

    function cleanup() {
    rm -rf "$TMPDIR"
    }

    trap cleanup EXIT

    server=${1:-localhost}

    PXE_URL="tftp://$server/pxelinux.cfg/default-amd64-generic"
    curl -s "$PXE_URL" > "$TMPDIR/pxe-config"

    echo ""
    echo "===== BEGIN PXE CONFIG ====="
    cat "$TMPDIR/pxe-config"
    echo "===== END PXE CONFIG ====="

    CONFIG_URL=$(cat "$TMPDIR/pxe-config" \
    | grep ' APPEND.*cloud-config-url' \
    | tr ' ' '\n' \
    | grep cloud-config-url \
    | cut -f2- -d=)
    echo ""
    echo "Found cloud-config-url: $CONFIG_URL"
    curl -s "$CONFIG_URL" > "$TMPDIR/enlist-config"

    echo ""
    echo "===== BEGIN ENLISTMENT CLOUD-CONFIG ====="
    cat "$TMPDIR/enlist-config"
    echo "===== END ENLISTMENT CLOUD-CONFIG ====="

    METADATA_URL=$(cat "$TMPDIR/enlist-config" \
    | grep 'metadata_url: ' \
    | awk '{ print $2 }')
    echo ""
    echo "Found metadata URL: $METADATA_URL"