#!/bin/bash

PATH=/usr/bin:/usr/sbin

. /usr/lib/rc/functions

stat_busy "Stop services ..." sv force-stop /run/runit/service/*
stat_done
stat_busy "Exit services ..." sv exit /run/runit/service/*
stat_done

if [ -e /run/runit/reboot ]; then
    chmod 100 /run/runit/reboot
fi

run_shutdown

if [ -e /run/runit/reboot ]; then
    [[ -x $(type -P kexec) ]] && kexec -e &>/dev/null
fi

status "Stage 3 completed."
