#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
# halt under kw-init: SIGUSR1 to PID 1 (powers off); another user through sudo -n.

# unkernel: halt under kw-init.
trap 'exit 0' TERM   # kw-init stops everything: no "Terminated"
if [ "$(id -u)" != 0 ]; then
	sudo -n /usr/local/sbin/halt "$@"
	exit
fi
kill -USR1 1
sleep 10
