#!/hint/bash require_module "$(dirname -- "${BASH_SOURCE[0]}")/testuser.sh" post_install+=(10:systemd-runscript:post_install) systemd-runscript:post_install() { local arg_mountpoint=$1 cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/runscript.target" [Unit] Description=runscript target Requires=multi-user.target After=multi-user.target Conflicts=rescue.target AllowIsolate=yes EOT ln -sT testsuite.target "${arg_mountpoint}/etc/systemd/system/default.target" cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/runscript.service" [Unit] Description=runscript service [Service] Type=oneshot ExecStart=/bin/sh -c 'su testuser -c /etc/runscript > /var/log/runscript.out; echo $? > /var/log/runscript.status' ExecStopPost=/bin/systemctl poweroff --no-block [Install] WantedBy=runscript.target EOT systemctl --root="$arg_mountpoint" enable runscript.service }