two-images/packer/scripts/rocky.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

63 lines
1.8 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
die () { echo "!! ${1}" >&2; exit 1; }
unit_exists () {
[ -e "/mnt/usr/lib/systemd/system/${1}" ] || [ -e "/mnt/etc/systemd/system/${1}" ]
}
echo "The default user for Syonad VMs is 'syonad'." > /mnt/etc/banner
augtool -r /mnt -s <<'EOF'
set /files/etc/ssh/sshd_config/X11Forwarding no
set /files/etc/ssh/sshd_config/PermitTunnel no
set /files/etc/ssh/sshd_config/PermitRootLogin no
set /files/etc/ssh/sshd_config/RSAAuthentication yes
set /files/etc/ssh/sshd_config/PubkeyAuthentication yes
set /files/etc/ssh/sshd_config/PasswordAuthentication no
set /files/etc/ssh/sshd_config/UseDNS no
set /files/etc/ssh/sshd_config/ChallengeResponseAuthentication no
set /files/etc/ssh/sshd_config/GSSAPIAuthentication no
set /files/etc/ssh/sshd_config/Match[1]/Condition/User "root,centos,ubuntu,debian,ec2-user"
set /files/etc/ssh/sshd_config/Match[1]/Settings/Banner "/etc/banner"
EOF
cat > /mnt/etc/cloud/cloud.cfg.d/20_user.cfg <<'EOF'
system_info:
default_user:
name: syonad
EOF
install -m 0600 /dev/stdin /mnt/etc/NetworkManager/system-connections/90-all-en.nmconnection <<'EOF'
[connection]
id=two-all-en
type=ethernet
autoconnect-priority=-100
multi-connect=3
[match]
interface-name=en*
[ipv4]
method=auto
[ipv6]
method=ignore
EOF
chroot /mnt systemctl enable fstrim.timer
for unit in rpcbind.service rpcbind.socket; do
if unit_exists "${unit}"; then
chroot /mnt systemctl disable "${unit}"
fi
done
augtool -r /mnt -s set /files/etc/selinux/config/SELINUX disabled
mapfile -t cockpit < <(chroot /mnt rpm -qa 'cockpit*')
if [ "${#cockpit[@]}" -gt 0 ]; then
chroot /mnt dnf -y -q --disablerepo='*' remove "${cockpit[@]}"
fi
[ -z "$(chroot /mnt rpm -qa 'cockpit*')" ] || die "cockpit toujours installé"
rm -rf /mnt/run/cockpit