#!/bin/sh

set -eu
IFS="$(printf '\n\t')"

# Prepares the device for running of the google-cast unit tests.  This
# script is idempotent: it can be run multiple times and the end state
# will always be the same; always run this script before starting the
# unit tests.

/etc/init.d/nsdk stop

umount /data/usb || true
rm -rf /data
rsync -a /media/settings/google-cast /data

mount /media/sda1/ -o remount,rw
mkdir -p /data/usb
mount /dev/sda1 /data/usb -o umask=0 -t vfat

if [ ! -L /dev/block/sda1 ]; then
    ln -s /dev/sda1 /dev/block/sda1
fi

# streamsdk / cast_shell should be stopped before trying to start the
# unit tests, so don't restart it here.
