#!/bin/sh # configure.sh — runs inside chroot after base install and overlay copy. # Invoked via alpine-make-vm-image --script-chroot. set -eu _step_counter=0 step() { _step_counter=$(( _step_counter + 1 )) printf '\n\033[1;36m%d) %s\033[0m\n' $_step_counter "$@" >&2 } uname -a # ------------------------------------------------------------------- step 'Set timezone to UTC' setup-timezone -z UTC # ------------------------------------------------------------------- step 'Set up networking' # The interfaces file was placed by --fs-skel-dir; link init.d scripts. ln -sf networking /etc/init.d/net.lo ln -sf networking /etc/init.d/net.eth0 # ------------------------------------------------------------------- step 'Adjust rc.conf' sed -Ei \ -e 's/^[# ](rc_depend_strict)=.*/\1=NO/' \ -e 's/^[# ](rc_logger)=.*/\1=YES/' \ -e 's/^[# ](unicode)=.*/\1=YES/' \ /etc/rc.conf # ------------------------------------------------------------------- step 'Enable base services' rc-update add net.lo boot rc-update add net.eth0 default rc-update add acpid default # ------------------------------------------------------------------- step 'Enable Docker' rc-update add docker default # ------------------------------------------------------------------- step 'Create docker data directory on /data' mkdir -p /data/docker # ------------------------------------------------------------------- step 'Import GPG key for root' GPG_KEY_FILE="/root/gpg-key.asc" if [ -f "$GPG_KEY_FILE" ]; then echo "Found GPG key file: $GPG_KEY_FILE" gpg --batch --import "$GPG_KEY_FILE" # Mark the imported key as ultimately trusted (non-interactive) fingerprint=$(gpg --batch --with-colons --fingerprint \ | grep '^fpr:' | head -1 | cut -d: -f10) if [ -n "$fingerprint" ]; then echo "$fingerprint:6:" | gpg --batch --import-ownertrust echo " * GPG key trusted: $fingerprint" fi rm -f "$GPG_KEY_FILE" else echo "WARNING: GPG key file not found at $GPG_KEY_FILE — skipping import" >&2 fi # ------------------------------------------------------------------- step 'Clean up APK cache' rm -rf /var/cache/apk/* || true echo '' echo '=== Configure script completed ==='