From 44e0707d428de04919a33f325d4e612335bdb777 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 28 Apr 2021 13:04:48 +0200 Subject: good testing environment --- .gitignore | 3 + .../system/getty@tty1.service.d/autologin.conf | 3 + airootfs/root/bootstrap | 28 ++++ build | 3 + packages.x86_64 | 9 +- profiledef.sh | 9 +- run_archiso | 174 +++++++++++++++++++++ test | 7 + 8 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf create mode 100755 airootfs/root/bootstrap create mode 100755 build create mode 100755 run_archiso create mode 100755 test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8926638 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tmp/ +images/ +main diff --git a/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf b/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf new file mode 100644 index 0000000..d1d8474 --- /dev/null +++ b/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux diff --git a/airootfs/root/bootstrap b/airootfs/root/bootstrap new file mode 100755 index 0000000..456345c --- /dev/null +++ b/airootfs/root/bootstrap @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +if ! timeout 1 curl -Is tombarrett.xyz | grep "200 OK" > /dev/null; then + echo "Please first connect to the internet." + exit +fi + +if ! test -b "$1"; then + echo "Please pass an existing drive as an argument. ie /dev/sda" + exit +fi + +parted -s "$1" mklabel gpt + +if ! test -f "/sys/firmware/efi/efivars"; then + parted "$1" mkpart bios ext4 0% 513MiB + parted "$1" set 1 bios_grub on + parted "$1" mkpart home ext4 513MiB 100% +else + parted "$1" mkpart efi fat32 0% 513MiB + parted "$1" set 1 esp on + parted "$1" mkpart home ext4 513MiB 100% +fi + +mount "$1"2 /mnt + +timedatectl set-ntp true diff --git a/build b/build new file mode 100755 index 0000000..74fe18d --- /dev/null +++ b/build @@ -0,0 +1,3 @@ +#!/bin/bash +rm -rf tmp +mkarchiso -v -w tmp -o images . diff --git a/packages.x86_64 b/packages.x86_64 index 251e122..8e8f80c 100644 --- a/packages.x86_64 +++ b/packages.x86_64 @@ -1,9 +1,14 @@ -# -# SPDX-License-Identifier: GPL-3.0-or-later base +bash cloud-init linux +linux-firmware mkinitcpio mkinitcpio-archiso openssh +parted +ranger +rsync syslinux +vim +wget diff --git a/profiledef.sh b/profiledef.sh index 7c89c0f..a44ab1a 100644 --- a/profiledef.sh +++ b/profiledef.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # shellcheck disable=SC2034 -iso_name="archlinux-baseline" -iso_label="ARCH_$(date +%Y%m)" -iso_publisher="Arch Linux " -iso_application="Arch Linux baseline" +iso_name="toms_arch" +iso_label="_$(date +%Y%m)" +iso_publisher="Tom Barrett " +iso_application="toms archlinux installer" iso_version="$(date +%Y.%m.%d)" install_dir="arch" bootmodes=('bios.syslinux.mbr' 'bios.syslinux.eltorito' 'uefi-x64.systemd-boot.esp' 'uefi-x64.systemd-boot.eltorito') @@ -14,4 +14,5 @@ airootfs_image_type="squashfs" airootfs_image_tool_options=('-comp' 'xz' '-Xbcj' 'x86' '-b' '1M' '-Xdict-size' '1M') file_permissions=( ["/etc/shadow"]="0:0:400" + ["/root/bootstrap"]="0:0:700" ) diff --git a/run_archiso b/run_archiso new file mode 100755 index 0000000..983a003 --- /dev/null +++ b/run_archiso @@ -0,0 +1,174 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2020 David Runge +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# A simple script to run an archiso image using qemu. The image can be booted +# using BIOS or UEFI. +# +# Requirements: +# - qemu +# - edk2-ovmf (when UEFI booting) + + +set -eu + +print_help() { + local usagetext + IFS='' read -r -d '' usagetext < 0 )); then + while getopts 'abc:dhi:suv' flag; do + case "$flag" in + a) + accessibility='on' + ;; + b) + boot_type='bios' + ;; + c) + oddimage="$OPTARG" + ;; + d) + mediatype='hd' + ;; + h) + print_help + exit 0 + ;; + i) + image="$OPTARG" + ;; + u) + boot_type='uefi' + ;; + s) + secure_boot='on' + ;; + v) + display='none' + qemu_options+=(-vnc 'vnc=0.0.0.0:0,vnc=[::]:0') + ;; + *) + printf '%s\n' "Error: Wrong option. Try 'run_archiso -h'." + exit 1 + ;; + esac + done +else + print_help + exit 1 +fi + +check_image +run_image diff --git a/test b/test new file mode 100755 index 0000000..7a6987b --- /dev/null +++ b/test @@ -0,0 +1,7 @@ +#!/bin/bash + +if ! test -f "main"; then + qemu-img create main 20G +fi + +./run_archiso -u -i images/$(ls images | sort | tail -n 1) -- cgit v1.2.3