two-images/packer/scripts/clean.sh
GnomeZworc fe401b9a12
Some checks failed
Tests / check (push) Failing after 39s
two-images: construction reproductible de rocky10 et debian13 par Packer, test de démarrage syonad/two#53
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
2026-10-24 13:53:56 +02:00

20 lines
592 B
Bash

#!/usr/bin/env bash
set -euo pipefail
empty_dir () {
[ -d "${1}" ] && find "${1}" -mindepth 1 -delete
return 0
}
for d in /mnt/var/cache/dnf /mnt/var/cache/yum /mnt/root/.ssh /mnt/tmp /mnt/var/tmp /mnt/var/lib/dhcp /mnt/var/lib/cloud; do
empty_dir "${d}"
done
rm -f /mnt/root/.bash_history
find /mnt/var/log ! -type d -delete
find /mnt/etc/ssh -maxdepth 1 -name 'ssh_host_*' -delete
if [ -f /mnt/etc/machine-id ]; then
: > /mnt/etc/machine-id
fi
if [ -f /mnt/var/lib/dbus/machine-id ] && [ ! -L /mnt/var/lib/dbus/machine-id ]; then
rm -f /mnt/var/lib/dbus/machine-id
fi