Skip to content

Instantly share code, notes, and snippets.

@Lokawn
Forked from sfan5/alpine-container.sh
Created August 27, 2024 16:52
Show Gist options
  • Save Lokawn/52bf52fa78a0aec017cd3dcefb9df41f to your computer and use it in GitHub Desktop.
Save Lokawn/52bf52fa78a0aec017cd3dcefb9df41f to your computer and use it in GitHub Desktop.

Revisions

  1. @sfan5 sfan5 revised this gist Jul 26, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.19}
    VERSION=${VERSION:-v3.20}
    APKTOOLS_VERSION=2.14.4-r0


  2. @sfan5 sfan5 revised this gist May 11, 2024. 3 changed files with 13 additions and 8 deletions.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.19}
    APKTOOLS_VERSION=2.14.3-r1
    APKTOOLS_VERSION=2.14.4-r0


    wget_or_curl () {
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1 --numeric-owner

    # configure mirror
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    printf 'Server = %s/$repo/os/$arch\n' "$MIRROR" >"$dest"/etc/pacman.d/mirrorlist
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    # https://github.com/systemd/systemd/issues/852
    17 changes: 11 additions & 6 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Ubuntu

    CODENAME=${CODENAME:-jammy}
    CODENAME=${CODENAME:-noble}

    wget_or_curl () {
    if command -v wget >/dev/null; then
    @@ -50,12 +50,17 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    # https://github.com/systemd/systemd/issues/852
    [ -f "$dest/etc/securetty" ] && \
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    # container needs no mounts
    >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # uninstall some packages
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd, cloud-init' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd cloud-init
    # disable services and uninstall packages
    systemd-nspawn -q -D "$dest" sh -c '
    [ -s /etc/environment ] && . /etc/environment
    for unit in ssh.service ssh.socket systemd-timesyncd systemd-networkd-wait-online systemd-resolved; do
    systemctl is-enabled "$unit" && systemctl disable "$unit"
    done
    apt-get -qq satisfy -y --purge "Conflicts: lxcfs, lxd, snapd, cloud-init" || \
    apt-get -qq purge --autoremove snapd lxcfs lxd cloud-init
    '


    echo ""
  3. @sfan5 sfan5 revised this gist Apr 8, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -58,7 +58,7 @@ $apkdir/sbin/apk.static \

    mkdir -p "$dest"/{etc/apk,root}
    # configure mirror
    printf '%s/%s/main\n%s/%s/community\n' $MIRROR $VERSION >"$dest"/etc/apk/repositories
    printf '%s/%s/main\n%s/%s/community\n' "$MIRROR" $VERSION "$MIRROR" $VERSION >"$dest"/etc/apk/repositories
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
  4. @sfan5 sfan5 revised this gist Apr 5, 2024. 3 changed files with 88 additions and 22 deletions.
    46 changes: 36 additions & 10 deletions alpine-container.sh
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -3,36 +3,62 @@

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.19}
    APKTOOLS_VERSION=2.14.0-r5
    APKTOOLS_VERSION=2.14.3-r1


    wget_or_curl () {
    if command -v wget >/dev/null; then
    wget -qO- "$1"
    elif command -v curl >/dev/null; then
    curl -Ls "$1"
    else
    echo "missing either curl or wget" >&2
    return 1
    fi
    }

    if [ $UID -ne 0 ]; then
    echo "run this script as root" >&2
    exit 1
    fi

    if [ -z "$1" ]; then
    dest="$1"
    if [ -z "$dest" ]; then
    echo "Usage: $0 <destination>" >&2
    exit 0
    fi
    if [ -e "$dest/usr/bin" ]; then
    echo "destination already seems to contain a root file system" >&2
    exit 1
    fi

    dest="$1"
    if [[ "$(uname -m)" =~ ^i[3456]86|x86 ]]; then
    toolarch=x86
    guestarch=$toolarch
    [ "$(uname -m)" = x86_64 ] && guestarch=x86_64
    elif [[ "$(uname -m)" =~ ^arm|aarch64 ]]; then
    toolarch=armv7
    guestarch=$toolarch
    [ "$(uname -m)" = aarch64 ] && guestarch=aarch64
    else
    echo "unsupported architecture" >&2
    exit 1
    fi
    apkdir=$(mktemp -d)
    guestarch=x86
    [ "$(uname -m)" == x86_64 ] && guestarch=x86_64
    trap 'rm -r $apkdir' EXIT
    trap 'rm -rf $apkdir' EXIT

    wget -qO- $MIRROR/latest-stable/main/x86/apk-tools-static-$APKTOOLS_VERSION.apk \
    wget_or_curl "$MIRROR/latest-stable/main/$toolarch/apk-tools-static-$APKTOOLS_VERSION.apk" \
    | tar -xz -C $apkdir || \
    { echo "Couldn't download apk-tools, the version might have changed..."; exit 1; }
    { echo "couldn't download apk-tools, the version might have changed..." >&2; exit 1; }

    $apkdir/sbin/apk.static \
    -X $MIRROR/$VERSION/main -U --arch $guestarch \
    --allow-untrusted --root "$dest" \
    --initdb add alpine-base

    mkdir -p "$dest"/{etc/apk,root}
    printf '%s/%s/main\n' $MIRROR $VERSION >"$dest"/etc/apk/repositories
    # configure mirror
    printf '%s/%s/main\n%s/%s/community\n' $MIRROR $VERSION >"$dest"/etc/apk/repositories
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    @@ -49,4 +75,4 @@ done


    echo ""
    echo "Alpine $VERSION container was created successfully."
    echo "Alpine $VERSION $guestarch container was created successfully."
    34 changes: 26 additions & 8 deletions arch-container.sh
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -6,38 +6,56 @@ ISO_DATE=latest
    PKG_GROUPS="base"


    wget_or_curl () {
    if command -v wget >/dev/null; then
    wget "$1" -O "$2"
    elif command -v curl >/dev/null; then
    curl -L "$1" -o "$2"
    else
    echo "missing either curl or wget" >&2
    return 1
    fi
    }

    if [ $UID -ne 0 ]; then
    echo "run this script as root" >&2
    exit 1
    fi

    if [ -z "$1" ]; then
    dest="$1"
    if [ -z "$dest" ]; then
    echo "Usage: $0 <destination>" >&2
    exit 0
    fi
    if [ -e "$dest/usr/bin" ]; then
    echo "destination already seems to contain a root file system" >&2
    exit 1
    fi

    dest="$1"
    [ "$(uname -m)" = x86_64 ] || { echo "unsupported architecture" >&2; exit 1; }
    tarfile=$(mktemp)
    trap 'rm $tarfile' EXIT

    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-x86_64.tar.gz" -O $tarfile
    wget_or_curl "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-x86_64.tar.gz" $tarfile

    mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1 --numeric-owner

    # configure mirror
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    # https://github.com/systemd/systemd/issues/852
    [ -f "$dest/etc/securetty" ] && \
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    cat >"$dest"/setup.sh <<SCRIPT
    # seems to be this bug https://github.com/systemd/systemd/issues/3611
    systemd-machine-id-setup --root="$dest"
    # install the packages
    systemd-nspawn -q -D "$dest" sh -c "
    pacman-key --init && pacman-key --populate
    pacman -Sy --noconfirm --needed ${PKG_GROUPS}
    rm /setup.sh
    SCRIPT
    systemd-nspawn -q -D "$dest" sh /setup.sh
    "


    echo ""
    echo "Arch Linux container was created successfully (bootstrapped from $ISO_DATE)"
    echo "Arch Linux container was created successfully (bootstrapped from $ISO_DATE)"
    30 changes: 26 additions & 4 deletions ubuntu-container.sh
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -3,22 +3,44 @@

    CODENAME=${CODENAME:-jammy}

    wget_or_curl () {
    if command -v wget >/dev/null; then
    wget "$1" -O "$2"
    elif command -v curl >/dev/null; then
    curl -L "$1" -o "$2"
    else
    echo "missing either curl or wget" >&2
    return 1
    fi
    }

    if [ $UID -ne 0 ]; then
    echo "run this script as root" >&2
    exit 1
    fi

    if [ -z "$1" ]; then
    dest="$1"
    if [ -z "$dest" ]; then
    echo "Usage: $0 <destination>" >&2
    exit 0
    fi
    if [ -e "$dest/usr/bin" ]; then
    echo "destination already seems to contain a root file system" >&2
    exit 1
    fi

    dest="$1"
    if [ "$(uname -m)" = x86_64 ]; then
    guestarch=amd64
    elif [ "$(uname -m)" = aarch64 ]; then
    guestarch=arm64
    else
    echo "unsupported architecture" >&2
    exit 1
    fi
    rootfs=$(mktemp)
    trap 'rm $rootfs' EXIT

    wget "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-amd64-root.tar.xz" -O $rootfs
    wget_or_curl "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-${guestarch}-root.tar.xz" $rootfs

    mkdir -p "$dest"
    tar -xaf $rootfs -C "$dest" --numeric-owner
    @@ -37,4 +59,4 @@ systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts:


    echo ""
    echo "Ubuntu $CODENAME container was created successfully"
    echo "Ubuntu $CODENAME $guestarch container was created successfully"
  5. @sfan5 sfan5 revised this gist Feb 25, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.18}
    APKTOOLS_VERSION=2.14.0-r2
    VERSION=${VERSION:-v3.19}
    APKTOOLS_VERSION=2.14.0-r5


    if [ $UID -ne 0 ]; then
  6. @sfan5 sfan5 revised this gist Oct 20, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2023.07.01
    ISO_DATE=latest
    PKG_GROUPS="base"


    @@ -20,7 +20,7 @@ dest="$1"
    tarfile=$(mktemp)
    trap 'rm $tarfile' EXIT

    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz" -O $tarfile
    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-x86_64.tar.gz" -O $tarfile

    mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1 --numeric-owner
  7. @sfan5 sfan5 revised this gist Jul 8, 2023. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.17}
    APKTOOLS_VERSION=2.12.10-r1
    VERSION=${VERSION:-v3.18}
    APKTOOLS_VERSION=2.14.0-r2


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2022.12.01
    ISO_DATE=2023.07.01
    PKG_GROUPS="base"


  8. @sfan5 sfan5 revised this gist Dec 5, 2022. 3 changed files with 8 additions and 8 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.16}
    APKTOOLS_VERSION=2.12.9-r3
    VERSION=${VERSION:-v3.17}
    APKTOOLS_VERSION=2.12.10-r1


    if [ $UID -ne 0 ]; then
    6 changes: 3 additions & 3 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2022.11.01
    ISO_DATE=2022.12.01
    PKG_GROUPS="base"


    @@ -23,7 +23,7 @@ trap 'rm $tarfile' EXIT
    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz" -O $tarfile

    mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1
    tar -xzf $tarfile -C "$dest" --strip-components=1 --numeric-owner

    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    @@ -32,7 +32,7 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    [ -f "$dest/etc/securetty" ] && \
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    cat >"$dest"/setup.sh <<SCRIPT
    pacman-key --init && pacman-key --populate archlinux
    pacman-key --init && pacman-key --populate
    pacman -Sy --noconfirm --needed ${PKG_GROUPS}
    rm /setup.sh
    SCRIPT
    6 changes: 3 additions & 3 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ trap 'rm $rootfs' EXIT
    wget "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-amd64-root.tar.xz" -O $rootfs

    mkdir -p "$dest"
    tar -xaf $rootfs -C "$dest"
    tar -xaf $rootfs -C "$dest" --numeric-owner

    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    @@ -32,8 +32,8 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # uninstall some packages
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd, cloud-init' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd cloud-init


    echo ""
  9. @sfan5 sfan5 revised this gist Nov 4, 2022. 3 changed files with 7 additions and 7 deletions.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -20,11 +20,11 @@ dest="$1"
    apkdir=$(mktemp -d)
    guestarch=x86
    [ "$(uname -m)" == x86_64 ] && guestarch=x86_64
    trap 'rm -r $apkdir' EXIT

    wget -qO- $MIRROR/latest-stable/main/x86/apk-tools-static-$APKTOOLS_VERSION.apk \
    | tar -xz -C $apkdir || \
    { echo "Couldn't download apk-tools, the version might have changed..."; exit 1; }
    trap 'rm -r $apkdir' EXIT

    $apkdir/sbin/apk.static \
    -X $MIRROR/$VERSION/main -U --arch $guestarch \
    10 changes: 5 additions & 5 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2022.07.01
    ISO_DATE=2022.11.01
    PKG_GROUPS="base"


    @@ -18,19 +18,19 @@ fi

    dest="$1"
    tarfile=$(mktemp)
    trap 'rm $tarfile' EXIT

    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz" -O $tarfile
    trap 'rm $tarfile' EXIT

    mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    # https://github.com/systemd/systemd/issues/852
    [ -f "$dest/etc/securetty" ] && \
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    cat >"$dest"/setup.sh <<SCRIPT
    pacman-key --init && pacman-key --populate archlinux
    pacman -Sy --noconfirm --needed ${PKG_GROUPS}
    2 changes: 1 addition & 1 deletion ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -16,9 +16,9 @@ fi

    dest="$1"
    rootfs=$(mktemp)
    trap 'rm $rootfs' EXIT

    wget "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-amd64-root.tar.xz" -O $rootfs
    trap 'rm $rootfs' EXIT

    mkdir -p "$dest"
    tar -xaf $rootfs -C "$dest"
  10. @sfan5 sfan5 revised this gist Jul 7, 2022. 3 changed files with 5 additions and 5 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.15}
    APKTOOLS_VERSION=2.12.7-r3
    VERSION=${VERSION:-v3.16}
    APKTOOLS_VERSION=2.12.9-r3


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2022.04.05
    ISO_DATE=2022.07.01
    PKG_GROUPS="base"


    4 changes: 2 additions & 2 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Ubuntu

    CODENAME=${CODENAME:-focal}
    CODENAME=${CODENAME:-jammy}


    if [ $UID -ne 0 ]; then
    @@ -30,7 +30,7 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # uninstall some packages
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd
  11. @sfan5 sfan5 revised this gist Apr 19, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2022.01.01
    ISO_DATE=2022.04.05
    PKG_GROUPS="base"


  12. @sfan5 sfan5 revised this gist Jan 19, 2022. 3 changed files with 4 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.14}
    APKTOOLS_VERSION=2.12.7-r0
    VERSION=${VERSION:-v3.15}
    APKTOOLS_VERSION=2.12.7-r3


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2021.08.01
    ISO_DATE=2022.01.01
    PKG_GROUPS="base"


    2 changes: 1 addition & 1 deletion ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # packages that are useless inside container
    # uninstall some packages
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd

  13. @sfan5 sfan5 revised this gist Aug 11, 2021. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.13}
    APKTOOLS_VERSION=2.12.5-r1
    VERSION=${VERSION:-v3.14}
    APKTOOLS_VERSION=2.12.7-r0


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2021.06.01
    ISO_DATE=2021.08.01
    PKG_GROUPS="base"


  14. @sfan5 sfan5 revised this gist Jun 28, 2021. 3 changed files with 6 additions and 6 deletions.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.13}
    APKTOOLS_VERSION=2.12.5-r0
    APKTOOLS_VERSION=2.12.5-r1


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2021.05.01
    ISO_DATE=2021.06.01
    PKG_GROUPS="base"


    8 changes: 4 additions & 4 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -25,10 +25,10 @@ tar -xaf $rootfs -C "$dest"

    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    echo >"$dest/etc/fstab"
    # https://github.com/systemd/systemd/issues/852
    [ -f "$dest/etc/securetty" ] && \
    printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty"
    >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # packages that are useless inside container
  15. @sfan5 sfan5 revised this gist May 24, 2021. 2 changed files with 3 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.13}
    APKTOOLS_VERSION=2.12.1-r0
    APKTOOLS_VERSION=2.12.5-r0


    if [ $UID -ne 0 ]; then
    3 changes: 2 additions & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2021.02.01
    ISO_DATE=2021.05.01
    PKG_GROUPS="base"


    @@ -26,6 +26,7 @@ mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
  16. @sfan5 sfan5 revised this gist Feb 13, 2021. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.12}
    APKTOOLS_VERSION=2.10.5-r1
    VERSION=${VERSION:-v3.13}
    APKTOOLS_VERSION=2.12.1-r0


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2020.11.01
    ISO_DATE=2021.02.01
    PKG_GROUPS="base"


  17. @sfan5 sfan5 revised this gist Nov 19, 2020. 2 changed files with 3 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2020.09.01
    ISO_DATE=2020.11.01
    PKG_GROUPS="base"


    3 changes: 2 additions & 1 deletion ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,8 @@ echo >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # packages that are useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd'
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd' || \
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq purge --autoremove snapd lxcfs lxd


    echo ""
  18. @sfan5 sfan5 revised this gist Sep 10, 2020. 3 changed files with 5 additions and 5 deletions.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://nl.alpinelinux.org/alpine
    MIRROR=http://dl-cdn.alpinelinux.org/alpine
    VERSION=${VERSION:-v3.12}
    APKTOOLS_VERSION=2.10.5-r1

    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2020.06.01
    ISO_DATE=2020.09.01
    PKG_GROUPS="base"


    6 changes: 3 additions & 3 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -30,9 +30,9 @@ for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    done
    echo >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    rsync ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq --autoremove purge -y snapd lxd
    ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # packages that are useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq satisfy -y --purge 'Conflicts: lxcfs, lxd, snapd'


    echo ""
  19. @sfan5 sfan5 revised this gist Jul 5, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -28,8 +28,9 @@ rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    echo >"$dest/etc/fstab"
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    rsync ssh systemd-{timesyncd,networkd,resolved}
    rsync ssh systemd-{timesyncd,networkd-wait-online,resolved}
    # useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq --autoremove purge -y snapd lxd

  20. @sfan5 sfan5 revised this gist Jun 10, 2020. 3 changed files with 5 additions and 5 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://nl.alpinelinux.org/alpine
    VERSION=v3.11
    APKTOOLS_VERSION=2.10.4-r3
    VERSION=${VERSION:-v3.12}
    APKTOOLS_VERSION=2.10.5-r1


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2020.01.01
    ISO_DATE=2020.06.01
    PKG_GROUPS="base"


    4 changes: 2 additions & 2 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Ubuntu

    CODENAME=bionic
    CODENAME=${CODENAME:-focal}


    if [ $UID -ne 0 ]; then
    @@ -31,7 +31,7 @@ done
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    rsync ssh systemd-{timesyncd,networkd,resolved}
    # useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq --autoremove purge -y snapd lxcfs lxd
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq --autoremove purge -y snapd lxd


    echo ""
  21. @sfan5 sfan5 revised this gist Mar 6, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@
    # Creates a systemd-nspawn container with Alpine

    MIRROR=http://nl.alpinelinux.org/alpine
    ARCH=x86_64
    VERSION=v3.11
    APKTOOLS_VERSION=2.10.4-r3

  22. @sfan5 sfan5 revised this gist Jan 10, 2020. 3 changed files with 30 additions and 21 deletions.
    11 changes: 8 additions & 3 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@

    MIRROR=http://nl.alpinelinux.org/alpine
    ARCH=x86_64
    VERSION=v3.10
    APKTOOLS_VERSION=2.10.4-r2
    VERSION=v3.11
    APKTOOLS_VERSION=2.10.4-r3


    if [ $UID -ne 0 ]; then
    @@ -25,6 +25,7 @@ guestarch=x86
    wget -qO- $MIRROR/latest-stable/main/x86/apk-tools-static-$APKTOOLS_VERSION.apk \
    | tar -xz -C $apkdir || \
    { echo "Couldn't download apk-tools, the version might have changed..."; exit 1; }
    trap 'rm -r $apkdir' EXIT

    $apkdir/sbin/apk.static \
    -X $MIRROR/$VERSION/main -U --arch $guestarch \
    @@ -33,8 +34,13 @@ $apkdir/sbin/apk.static \

    mkdir -p "$dest"/{etc/apk,root}
    printf '%s/%s/main\n' $MIRROR $VERSION >"$dest"/etc/apk/repositories
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    # make console work
    sed '/tty[0-9]:/ s/^/#/' -i "$dest"/etc/inittab
    printf 'console::respawn:/sbin/getty 38400 console\n' >>"$dest"/etc/inittab
    # minimal boot services
    for s in hostname bootmisc syslog; do
    ln -s /etc/init.d/$s "$dest"/etc/runlevels/boot/$s
    done
    @@ -43,6 +49,5 @@ for s in killprocs savecache; do
    done


    rm -r $apkdir
    echo ""
    echo "Alpine $VERSION container was created successfully."
    19 changes: 11 additions & 8 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2019.11.01
    ISO_DATE=2020.01.01
    PKG_GROUPS="base"


    @@ -19,21 +19,24 @@ fi
    dest="$1"
    tarfile=$(mktemp)

    wget $MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz -O $tarfile
    mkdir "$dest"
    wget "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz" -O $tarfile
    trap 'rm $tarfile' EXIT

    mkdir -p "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    cat >"$dest"/setup.sh <<SCRIPT
    pacman-key --init
    pacman-key --populate archlinux
    pacman-key --init && pacman-key --populate archlinux
    pacman -Sy --noconfirm --needed ${PKG_GROUPS}
    rm /setup.sh
    SCRIPT
    systemd-nspawn -q -D "$dest" sh /setup.sh
    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty


    rm $tarfile
    echo ""
    echo "Arch Linux container was created successfully. (bootstrapped from $ISO_DATE)"
    echo "Arch Linux container was created successfully (bootstrapped from $ISO_DATE)"
    21 changes: 11 additions & 10 deletions ubuntu-container.sh
    Original file line number Diff line number Diff line change
    @@ -18,20 +18,21 @@ dest="$1"
    rootfs=$(mktemp)

    wget "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-amd64-root.tar.xz" -O $rootfs
    trap 'rm $rootfs' EXIT

    mkdir -p "$dest"
    tar -xaf $rootfs -C "$dest"

    sed '/^root:/ s|\*||' -i "$dest/etc/shadow"
    rm "$dest/etc/resolv.conf" "$dest/etc/securetty"
    disable="ebtables rsync systemd-timesyncd snapd snapd.seeded"
    disable="$disable networkd-dispatcher systemd-networkd systemd-networkd-wait-online systemd-resolved"
    for s in $disable; do
    rm -f "$dest/etc/systemd/system/"*.target.wants"/$s.service" "$dest"/etc/rc[S5].d/S??"$s"
    sed '/^root:/ s|\*||' -i "$dest/etc/shadow" # passwordless login
    rm "$dest/etc/resolv.conf" # systemd configures this
    for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852
    echo "pts/$i" >>"$dest/etc/securetty"
    done
    # ssh and iscsi cause startup to hang
    systemd-nspawn -q -D "$dest" apt-get -qq purge -y openssh-server open-iscsi
    systemd-nspawn -q -D "$dest" /bin/systemctl disable \
    rsync ssh systemd-{timesyncd,networkd,resolved}
    # useless inside container
    systemd-nspawn -q -D "$dest" /usr/bin/apt-get -qq --autoremove purge -y snapd lxcfs lxd


    rm $rootfs
    echo ""
    echo "Ubuntu $CODENAME container was created successfully."
    echo "Ubuntu $CODENAME container was created successfully"
  23. @sfan5 sfan5 revised this gist Nov 17, 2019. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2019.09.01
    ISO_DATE=2019.11.01
    PKG_GROUPS="base"


    @@ -23,19 +23,17 @@ wget $MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz -O $tarfi
    mkdir "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    cat >"$dest"/setup.sh <<SCRIPT
    pacman-key --init
    pacman-key --populate archlinux
    pacman -Sy
    # avoid installing the kernel
    pacman -Sg ${PKG_GROUPS} | while read _ p;do [[ "\$p" == "linux"* ]]||echo "\$p";done | pacman -S --noconfirm --needed -
    pacman -Sy --noconfirm --needed ${PKG_GROUPS}
    rm /setup.sh
    SCRIPT
    systemd-nspawn -q -D "$dest" sh /setup.sh
    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty


    rm $tarfile
    echo ""
    echo "Arch $ISO_DATE container was created successfully."
    echo "Arch Linux container was created successfully. (bootstrapped from $ISO_DATE)"
  24. @sfan5 sfan5 revised this gist Sep 25, 2019. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirrors.n-ix.net/archlinux
    ISO_DATE=2019.08.01
    MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux
    ISO_DATE=2019.09.01
    PKG_GROUPS="base"


    @@ -25,16 +25,17 @@ tar -xzf $tarfile -C "$dest" --strip-components=1

    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    systemd-nspawn -q -D "$dest" --pipe sh <<SCRIPT
    cat >"$dest"/setup.sh <<SCRIPT
    pacman-key --init
    pacman-key --populate archlinux
    pacman -Sy
    # avoid installing the kernel
    pacman -Sg ${PKG_GROUPS} | while read _ p;do [[ "\$p" == "linux"* ]]||echo "\$p";done | pacman -S --noconfirm --needed -
    rm /setup.sh
    SCRIPT
    systemd-nspawn -q -D "$dest" sh /setup.sh


    rm $tarfile
    echo ""
    echo "Arch $ISO_DATE container was created successfully."
    echo "Arch $ISO_DATE container was created successfully."
  25. @sfan5 sfan5 revised this gist Aug 13, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/bash -e
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.rackspace.com/archlinux
    ISO_DATE=2019.07.01
    MIRROR=http://mirrors.n-ix.net/archlinux
    ISO_DATE=2019.08.01
    PKG_GROUPS="base"


  26. @sfan5 sfan5 revised this gist Jul 23, 2019. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@

    MIRROR=http://nl.alpinelinux.org/alpine
    ARCH=x86_64
    VERSION=v3.9
    APKTOOLS_VERSION=2.10.3-r1
    VERSION=v3.10
    APKTOOLS_VERSION=2.10.4-r2


    if [ $UID -ne 0 ]; then
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.rackspace.com/archlinux
    ISO_DATE=2019.05.02
    ISO_DATE=2019.07.01
    PKG_GROUPS="base"


  27. @sfan5 sfan5 revised this gist May 24, 2019. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.rackspace.com/archlinux
    ISO_DATE=2019.02.01
    PACKAGES="base"
    ISO_DATE=2019.05.02
    PKG_GROUPS="base"


    if [ $UID -ne 0 ]; then
    @@ -25,17 +25,16 @@ tar -xzf $tarfile -C "$dest" --strip-components=1

    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    systemd-nspawn -q -D "$dest" sh <<SCRIPT
    systemd-nspawn -q -D "$dest" --pipe sh <<SCRIPT
    pacman-key --init
    pacman-key --populate archlinux
    pacman -Sy
    # avoid installing the kernel
    pkgs=\$(pacman -Sg $PACKAGES | while read _ p;do [[ "\$p" == "linux"* ]]||echo -n "\$p ";done)
    pacman -S --noconfirm --needed \$pkgs
    pacman -Sg ${PKG_GROUPS} | while read _ p;do [[ "\$p" == "linux"* ]]||echo "\$p";done | pacman -S --noconfirm --needed -
    SCRIPT


    rm $tarfile
    echo ""
    echo "Arch $ISO_DATE container was created successfully."
    echo "Arch $ISO_DATE container was created successfully."
  28. @sfan5 sfan5 revised this gist Feb 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ wget $MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz -O $tarfi
    mkdir "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    rm "$dest"/etc/resolv.conf
    rm "$dest"/etc/resolv.conf "$dest"/etc/securetty
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    systemd-nspawn -q -D "$dest" sh <<SCRIPT
    pacman-key --init
  29. @sfan5 sfan5 revised this gist Feb 11, 2019. 2 changed files with 4 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@

    MIRROR=http://nl.alpinelinux.org/alpine
    ARCH=x86_64
    VERSION=v3.8
    APKTOOLS_VERSION=2.10.1-r0
    VERSION=v3.9
    APKTOOLS_VERSION=2.10.3-r1


    if [ $UID -ne 0 ]; then
    3 changes: 2 additions & 1 deletion arch-container.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # Creates a systemd-nspawn container with Arch Linux

    MIRROR=http://mirror.rackspace.com/archlinux
    ISO_DATE=2018.07.01
    ISO_DATE=2019.02.01
    PACKAGES="base"


    @@ -23,6 +23,7 @@ wget $MIRROR/iso/$ISO_DATE/archlinux-bootstrap-$ISO_DATE-x86_64.tar.gz -O $tarfi
    mkdir "$dest"
    tar -xzf $tarfile -C "$dest" --strip-components=1

    rm "$dest"/etc/resolv.conf
    printf 'Server = %s/$repo/os/$arch\n' $MIRROR >"$dest"/etc/pacman.d/mirrorlist
    systemd-nspawn -q -D "$dest" sh <<SCRIPT
    pacman-key --init
  30. @sfan5 sfan5 revised this gist Dec 16, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion alpine-container.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    MIRROR=http://nl.alpinelinux.org/alpine
    ARCH=x86_64
    VERSION=v3.8
    APKTOOLS_VERSION=2.10.0-r3
    APKTOOLS_VERSION=2.10.1-r0


    if [ $UID -ne 0 ]; then