Cleaning and tweaking (missing one-context?) of arch ONE script

This commit is contained in:
fnux 2021-03-11 10:56:06 +01:00
parent 71ecdae421
commit 5a0dbe8f82
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12

View file

@ -9,14 +9,12 @@ set -e
set -x set -x
# XXX: Handle command-line arguments? # XXX: Handle command-line arguments?
ARCH=amd64
IMAGE_PATH=arch-$(date --iso-8601).img.qcow2 IMAGE_PATH=arch-$(date --iso-8601).img.qcow2
IMAGE_SIZE=10G IMAGE_SIZE=10G
NBD_DEVICE=/dev/nbd0 NBD_DEVICE=/dev/nbd0
# TODO: find the package definition and built ourself, publish in some RPM repository. ONE_CONTEXT_VERSION=5.12.0.2
ONE_CONTEXT_DEB_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context_5.10.0-1.deb" ONE_CONTEXT_SOURCE_ARCHIVE="https://github.com/OpenNebula/addon-context-linux/archive/v$ONE_CONTEXT_VERSION.tar.gz"
ONE_CONTEXT_DEB_PATH=/root/one-context.deb
cleanup() { cleanup() {
# The order here is important. # The order here is important.
@ -42,9 +40,9 @@ if [ "$(whoami)" != 'root' ]; then
exit 1 exit 1
fi fi
if [ $(lsb_release --short --id) != "Arch" ]; then if [ "$(lsb_release --short --id)" != "Arch" ]; then
echo "WARNING: this script has been designed to run on an Ubuntu system." >&2 echo "WARNING: this script has been designed to run on Arch Linux." >&2
echo "WARNING: Not running Ubuntu. Giving you 5 seconds to abort." >&2 echo "WARNING: Not running Arch. Giving you 5 seconds to abort." >&2
sleep 5 sleep 5
fi fi
@ -75,7 +73,7 @@ mkdir /mnt/boot
mount "${NBD_DEVICE}p1" /mnt/boot mount "${NBD_DEVICE}p1" /mnt/boot
# Install base system. # Install base system.
pacstrap /mnt nbase base-devel openssh pacstrap /mnt base base-devel openssh
mount --bind /dev /mnt/dev mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts mount --bind /dev/pts /mnt/dev/pts
@ -84,9 +82,6 @@ mount --bind /proc /mnt/proc
mount --bind /run /mnt/run mount --bind /run /mnt/run
mount --bind /sys /mnt/sys mount --bind /sys /mnt/sys
# Guest networking is to be handled by the one-context package.
# See https://github.com/OpenNebula/addon-context-linux for details.
# Required to resolve package mirror in chroot. # Required to resolve package mirror in chroot.
cp /etc/resolv.conf /mnt/etc/resolv.conf cp /etc/resolv.conf /mnt/etc/resolv.conf
@ -105,16 +100,25 @@ cat > /mnt/etc/pacman.d/mirrorlist << EOF
## ##
## Switzerland ## Switzerland
Server = http://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch Server = http://pkg.adfinis-sygroup.ch/archlinux/\$repo/os/\$arch
Server = https://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch Server = https://pkg.adfinis-sygroup.ch/archlinux/\$repo/os/\$arch
Server = http://mirror.init7.net/archlinux/$repo/os/$arch Server = http://mirror.init7.net/archlinux/\$repo/os/\$arch
Server = https://mirror.init7.net/archlinux/$repo/os/$arch Server = https://mirror.init7.net/archlinux/\$repo/os/\$arch
Server = http://mirror.puzzle.ch/archlinux/$repo/os/$arch Server = http://mirror.puzzle.ch/archlinux/\$repo/os/\$arch
Server = https://mirror.puzzle.ch/archlinux/$repo/os/$arch Server = https://mirror.puzzle.ch/archlinux/\$repo/os/\$arch
Server = https://mirror.ungleich.ch/mirror/packages/archlinux/$repo/os/$arch Server = https://mirror.ungleich.ch/mirror/packages/archlinux/\$repo/os/\$arch
EOF EOF
run_root pacman --sync --refresh --upgrade run_root pacman --sync --refresh --upgrade
# Guest networking is to be handled by the one-context package.
# See https://github.com/OpenNebula/addon-context-linux for details.
run_root pacman --sync curl tar
run_root curl -L "$ONE_CONTEXT_SOURCE_ARCHIVE" -o one-context.tar.gz
run_root tar xf one-context.tar.gz
run_root cp -rT addon-context-linux-${ONE_CONTEXT_VERSION}/src/ /
run_root rm -r addon-context-linux-${ONE_CONTEXT_VERSION}
run_root systemctl enable one-context.service
# Initalize base services. # Initalize base services.
run_root systemd-machine-id-setup run_root systemd-machine-id-setup