#!/bin/sh # # multistrap-configure.sh # Copyright 2015 Jonas Smedegaard # License: GNU Public License version 3 or newer # # multistrap configscript invoked in rootfs to preseed and configure # # Recommends: debconf libfakeroot # # TODO: avoid need for libfakeroot installed into target system set -eu set -x # silence locale noise (esp. from perl) export LC_ALL=C LANGUAGE=C LANG=C \ # suppress debconf questions not preseeded export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true # dirty hack to make dash postinst succeed [ -n "$(dpkg-divert --list /bin/sh)" ] || /var/lib/dpkg/info/dash.preinst # preseed debconf questions cat /tmp/preseeds/* 2>&- | debconf-set-selections cat <<'EOF' >debconf-get #!/bin/sh # multistrap debconf wrapper to mimic d-i convenience command set -eu debconf-show d-i | grep -Po "(?<=. $1: ).*" EOF chmod +x debconf-get # add hostname file # FIXME: resolve from debconf cat <<'EOF' > /etc/hostname hamlet EOF # replace(!) hosts file # FIXME: resolve from debconf cat <<'EOF' > /etc/hosts 127.0.0.1 localhost 127.0.1.1 hamlet.jones.dk hamlet # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters EOF # add fstab file # FIXME: resolve from debconf # TODO: use UUID # : enable swap cat <<'EOF' > /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # # / was on /dev/mmcblk0p2 during installation /dev/mmcblk0p2 / ext4 errors=remount-ro 0 1 # /boot was on /dev/mmcblk0p1 during installation /dev/mmcblk0p1 /boot ext2 defaults 0 2 # swap was on /dev/mmcblk0p5 during installation #/dev/mmcblk0p5 none swap sw 0 0 EOF # passify flash-kernel, triggered by initramfs-tools hook on some archs export FK_MACHINE=none # configure packages dpkg --configure -a ./debconf-get preseed/late_command \ | PATH="$PATH:." perl -0777 -n \ -e 's,chroot\s+/target\s+,,g;' \ -e 's,/target/,/,g;' \ -e "s,'',,g;" \ -e 's,^\s+,,;' \ -e 'system($_) == 0 or die "Broken late_command:\n$_" if ($_);' # Create user account # FIXME: resolve from debconf adduser --disabled-login --gecos 'Debian User' --add_extra_groups debian && echo debian:insecure | chpasswd # sudo-enable initial user account # FIXME: resolve from debconf adduser debian sudo rm -f ./debconf-get # purge APT cache apt clean echo 'multistrap-configure.sh completed succesfully!' >&2