arch-iso-chainload-with-grub

script downloading once monthly the arch iso via scraped magnet link, copy the last iso and overwrite with current, grub grub.cfg for chainloading both images, systemd-boot grub.conf for chainloading grub.efi, systemd service and timer for once monthly o
Log | Files | Refs

commit 779af28a709bf88ac642617a6bc913f671e07139
Author: Jordan Beaver <jordan@beaveris.me>
Date:   Thu, 22 Aug 2024 18:42:31 -0700

script with service file and timer to download arch iso and maintain two
copies in /boot/isos.

Includes systemd-boot entry config to chainload grub, and grub config
file which requires username and password to boot the current or last
month iso.

Diffstat:
Aarch-iso-downloader | 16++++++++++++++++
Aarch-iso-downloader.service | 6++++++
Aarch-iso-downloader.timer | 10++++++++++
Agrub.cfg | 25+++++++++++++++++++++++++
Agrub.conf | 2++
5 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/arch-iso-downloader b/arch-iso-downloader @@ -0,0 +1,16 @@ +#!/bin/bash +magnet=$(curl -sLo /dev/stdout 'https://archlinux.org/download/' | htmlq 'a[title="Magnet link"]' -a 'href') +tracker="udp://tracker.opentrackr.org:1337/announce" +location="/tmp" +filename="archlinux-x86_64.iso" +isos="/boot/isos" + +if aria2c "$magnet" --bt-tracker "$tracker" --seed-time=0 -d "$location" -O 1="$filename" +then + cp "$isos/$filename" "$isos/last-$filename" + mv "$location/$filename" "$isos/$filename" + logger "Arch monthly iso downloaded successfully" +else + logger "Arch monthly iso download FAILED!" + exit 1 +fi diff --git a/arch-iso-downloader.service b/arch-iso-downloader.service @@ -0,0 +1,6 @@ +[Unit] +Description=Downloading latest installer iso for recovery purposes + +[Service] +Type=oneshot +ExecStart=arch-iso-downloader diff --git a/arch-iso-downloader.timer b/arch-iso-downloader.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Downloading latest installer iso for recovery purposes +Requires=network-online.target + +[Timer] +OnCalendar=*-*-10 *:*:* +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/grub.cfg b/grub.cfg @@ -0,0 +1,25 @@ +timeout=0 +insmod part_gpt +insmod part_msdos +set superusers="<user>" +password_pbkdf2 <user> <output of grub-mkpasswd-pbkdf2> + +menuentry '[loopback]archlinux-x86_64.iso' { + set iso_path='/isos/archlinux-x86_64.iso' + export iso_path + search --set=root --file "$iso_path" + loopback loop "$iso_path" + root=(loop) + configfile /boot/grub/loopback.cfg + loopback --delete loop +} + +menuentry '[loopback]last-archlinux-x86_64.iso' { + set iso_path='/isos/last-archlinux-x86_64.iso' + export iso_path + search --set=root --file "$iso_path" + loopback loop "$iso_path" + root=(loop) + configfile /boot/grub/loopback.cfg + loopback --delete loop +} diff --git a/grub.conf b/grub.conf @@ -0,0 +1,2 @@ +title ARCHISO +efi /EFI/GRUB/grubx64.efi