#!/usr/bin/env bash
#
# Build and installs whatever is in /usr/src. Run step 1, reboot, then step 2.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

sudo etcupdate -p

cd /usr/src
sudo make installworld
sudo etcupdate -B

if sudo etcupdate status | grep -qE '^  C '; then
    >&2 echo 'Conflicts in etcupdate. Run `etcupdate resolve` to fix them first.'
    exit 1
fi

echo "FreeBSD update step 2 done. Please reboot."
