archboot/usr/bin/archboot-server-update.sh
2024-07-27 11:31:45 +02:00

43 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
_APPNAME=${0##*/}
. /etc/archboot/defaults
. /etc/archboot/server-update.conf
. /usr/lib/archboot/common.sh
_usage () {
echo -e "\e[1mUpdate archboot server with new images\e[m"
echo -e "\e[1m---------------------------------------------\e[m"
echo "Check on new packages and release new images to server."
echo ""
echo -e "usage: \e[1m${_APPNAME} run\e[m"
exit 0
}
[[ -z "${1}" || "${1}" != "run" ]] && _usage
_root_check
[[ -d "${_ISO_HOME_CONTAINERS}" ]] || mkdir -p "${_ISO_HOME_CONTAINERS}"
cd "${_ISO_HOME_CONTAINERS}" || exit 1
# stop if MASK is set
[[ -e MASK ]] && exit 0
_FIRST_RUN=1
for i in ${_SERVER_ARCH}; do
[[ -z "${_FIRST_RUN}" ]] && sleep "${_SERVER_WAIT}"
_FIRST_RUN=""
# 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
rm "${i}"/var/cache/pacman/pkg/*
done
# vim: set ft=sh ts=4 sw=4 et: