#!/hint/bash -euE post_install+=(01:testuser:early) testuser:early() { local arg_mountpoint=$1 if ! grep -q ^testuser: -- "$arg_mountpoint/etc/passwd"; then chroot "$arg_mountpoint" useradd \ --gid=users \ --comment='Test User' \ --create-home \ testuser fi } post_install+=(90:testuser:late) testuser:late() { local arg_mountpoint=$1 local uidgid uidgid=$(awk -v FS=: -v OFS=: '$1 == "testuser" { print $3, $4 }' < "${arg_mountpoint}/etc/passwd") chown -R -- "$uidgid" "${arg_mountpoint}/home/testuser" }