#!/bin/sh

# Exit on error:
set -e

exec 2>&1

PATH=/bin

echo '4. Waiting for services to stop...'
sv down /service/*

echo '3. Exiting services...'
sv exit /service/*

echo '2. Deactivating all swap files/partitions...'
swapoff -a

# Unmount everything but /:
echo -n '1. Unmounting filesystems: /home'
umount -r /home
echo -n ' /proc'
umount -r /proc
echo -n ' /sys'
umount -r /sys
echo -n ' /dev/pts'
umount -r /dev/pts
echo ' /dev/shm'
umount -r /dev/shm

echo '0. Shutdown...'

exit 0
