#!/bin/sh
# Script to switch to execute sdcard environment scripts if available
#
# This enables an override of the default environment if an SD Card
# is inserted, has a FAT filesystem,  and has a barebox.env file in
# the root directory.

mci0.probe=1
if [ $mci0.probe = 1 ]; then
	mkdir /sdcard
	mount /dev/disk0.0 /sdcard
	if [ -f /sdcard/barebox.env ]; then
		loadenv /sdcard/barebox.env /env.sd
		/env.sd/bin/init
		exit
	fi
fi
trigger_error_return_code
exit
