#!/bin/sh

set -eu

. /usr/share/geordi/_functions

if [ -z "${RT}" ]
then
	Echo_error "Refusing to continue with empty \$RT"
	exit 1
fi

Echo_debug "Removing existing chroot"
rm -rf "${RT}"/*

Echo_debug "Creating chroot directory"
mkdir -p "${RT}"

Echo_debug "Copying advice.txt file"
if [ -e "${CONFIG_DIR}/advice.txt" ]
then
	cp "${CONFIG_DIR}/advice.txt" "${RT}"
else
	echo "E: ${CONFIG_DIR}/advice.txt was missing when this chroot was created." >> "${RT}/advice.txt"
fi
