File config.sh of Package kiwi-templates-Minimal

#!/bin/bash
# Minimal KIWI config for a live ISO (openSUSE Leap 15.5, console-only)
# Safe for images without cloud/RPi/hypervisor profiles

set -euxo pipefail

# Load KIWI environment helpers if present
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

# Optional marker used by YaST/jeos-firstboot; harmless if left
mkdir -p /var/lib/misc/reconfig_system

echo "Configure image: [$kiwi_iname] (profiles: [$kiwi_profiles])"

# ----- Basic cleanup & init -----------------------------------------------
echo "** reset machine settings"
rm -f /etc/machine-id \
      /var/lib/zypp/AnonymousUniqueId \
      /var/lib/systemd/random-seed

/sbin/ldconfig || true

# Set the base product symlink (provided by KIWI helpers)
suseSetupProduct || true

# Runlevel: 3 = multi-user (console). Change to 5 if you add a GUI.
baseSetRunlevel 3 || true

# Import SUSE build keys into RPM
suseImportBuildKey || true

# ----- Services you actually want -----------------------------------------
# Enable SSH if installed
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q '^sshd\.service'; then
    systemctl enable sshd.service || true
fi

# Enable chrony if its config exists (package installed)
if [ -f /etc/chrony.conf ]; then
    # suseInsertService is a KIWI helper; falls back to systemctl enable
    suseInsertService chronyd || systemctl enable chronyd || true
fi

# Enable firewalld only if present
if command -v firewall-cmd >/dev/null 2>&1; then
    systemctl enable firewalld || true
fi

# ----- Firstboot / JEOS (optional; keep guarded) --------------------------
# If you include jeos-firstboot in the image, this will run once.
if systemctl list-unit-files | grep -q '^jeos-firstboot\.service'; then
    mkdir -p /var/lib/YaST2
    : > /var/lib/YaST2/reconfig_system
    systemctl mask systemd-firstboot.service || true
    systemctl enable jeos-firstboot.service || true
fi

# ----- Console font & GRUB cosmetics --------------------------------------
CONSOLE_FONT="eurlatgr.psfu"
echo FONT="$CONSOLE_FONT" >> /etc/vconsole.conf

# Set GRUB2 to boot graphically
sed -Ei"" "s/#?GRUB_TERMINAL=.*/GRUB_TERMINAL=gfxterm/g" /etc/default/grub || true
sed -Ei"" "s/#?GRUB_GFXMODE=.*/GRUB_GFXMODE=auto/g" /etc/default/grub || true

# ----- Certificates & RPM keys --------------------------------------------
update-ca-certificates || true

# Import any shipped RPM pubkeys (ignore duplicates)
if ls /usr/lib/rpm/gnupg/keys/gpg-pubkey*asc >/dev/null 2>&1; then
  for i in /usr/lib/rpm/gnupg/keys/gpg-pubkey*asc; do
    rpm --import "$i" || true
  done
fi

# ----- Optional: Add YaST repos on live systems ---------------------------
# Only run if helper is present in the image; remove entirely if not needed.
if command -v add-yast-repos >/dev/null 2>&1; then
    add-yast-repos || true
    zypper --non-interactive rm -u live-add-yast-repos || true
fi

# ----- Snapper tuning (only if you choose btrfs root snapshot setup) ------
# Your live ISO is not using the btrfs snapshot root option; keep disabled.
# if [ "${kiwi_btrfs_root_is_snapshot-false}" = 'true' ]; then
#   # (snapper bootstrap here)
# fi

# ----- Remove RPi & cloud-specific code paths ------------------------------
# No Raspberry Pi or cloud-init in this image; skip those branches entirely.

# ----- Zypper defaults: lean image ----------------------------------------
# Prefer onlyRequires and exclude docs to keep the live image compact
sed -i 's/^.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf || true
sed -i 's/^.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf || true


exit 0
openSUSE Build Service is sponsored by