add server update scripts

This commit is contained in:
Tobias Powalowski 2024-07-24 21:30:04 +02:00
parent f13a12f294
commit 1a0bc04f98
6 changed files with 39 additions and 21 deletions

View file

@ -39,6 +39,7 @@ _CUSTOM_PACMAN_CONF="/etc/archboot/pacman.conf.archboot"
_CUSTOM_MIRRORLIST="/etc/archboot/mirrorlist.archboot"
# local paths
_ISO_HOME="/home/tobias/Arch/iso"
_ISO_HOME_CHROOTS="${_ISO_HOME}/chroots"
_ISO_HOME_ARCH="${_ISO_HOME}/${_ARCH}"
_ISO_HOME_SOURCE="${_ISO_HOME}/${_ARCH}/sources"
# external paths

View file

@ -0,0 +1,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
# set your managed architectures
_SERVER_ARCH="x86_64 aarch64 riscv64"
# set program updates that trigger new server release
_TRIGGER="archboot bcachefs-tools btrfs-progs coreutils cryptsetup \
device-mapper dosfstools e2fsprogs glibc iproute2 iputils iw \
iwd linux linux-firmware lvm2 mdadm openssh pacman systemd \
thin-provisioning-tools ttyd util-linux xfsprogs"

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
. /etc/archboot/defaults
. /etc/archboot/server-update.conf
[[ -d "${_ISO_HOME_CHROOTS}" ]] || mkdir -p "${_ISO_HOME_CHROOTS}"
cd "${_ISO_HOME_CHROOTS}"
# stop if MASK is set
[[ -e MASK ]] && exit 0
for i in ${_SERVER_ARCH}; do
# create container
if ! [[ -d "${i}" ]]; then
archboot-"${i}"-create-container.sh "${i}" -cp || exit 1
rm "${i}"/var/log/pacman.log
fi
# update container to latest packages
systemd-nspawn -q -D "${i}" pacman --noconfirm -Syu
for k in ${_TRIGGER}; do
# if trigger successful, release new image to server
if rg -qw "${k}" "${i}"/var/log/pacman.log; then
archboot-"${i}"-server-release.sh || echo "Error: ${i} release!" >> error.log
break
fi
done
rm "${i}"/var/log/pacman.log
done
# vim: set ft=sh ts=4 sw=4 et:

View file

@ -2,5 +2,5 @@
Description=Check, build and upload archboot images at night
[Service]
ExecStart=/home/tobias/Arch/iso/chroots/trigger-update.sh
ExecStart=/usr/bin/archboot-server-update.sh

View file

@ -4,7 +4,7 @@ Description=Runs trigger-update.sh at night
[Timer]
# Run everday at 2:00 night
OnCalendar=*-*-* 2:00:00
Unit=archboot.service
Unit=archboot-server-update.service
Persistent=true
[Install]

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
_ARCH="x86_64 aarch64 riscv64"
_TRIGGER="archboot bcachefs-tools btrfs-progs coreutils cryptsetup device-mapper dosfstools e2fsprogs glibc iproute2 iputils iw iwd linux linux-firmware lvm2 mdadm openssh pacman systemd thin-provisioning-tools ttyd util-linux xfsprogs"
_CHROOTS="/home/tobias/Arch/iso/chroots"
cd "${_CHROOTS}" || exit 1
[[ -e MASK ]] && exit 0
for i in ${_ARCH}; do
systemd-nspawn -q -D "${i}" pacman --noconfirm -Syu
for k in ${_TRIGGER}; do
if rg -qw "${k}" "${i}"/var/log/pacman.log; then
archboot-"${i}"-server-release.sh
break
fi
done
rm "${i}"/var/log/pacman.log
done
# vim: set ft=sh ts=4 sw=4 et: