#!/bin/sh
# Kill Carousel and amiberry
until [ `ps | grep -e amiberry | wc -l` -eq 1 ]
do
		killall -9 manhattan
        killall -9 amiberry
done

# Overmount /root for .bash_history
mount --bind /mnt/Yaft/root /root

# Clear keyboard buffer
while read -t 0.01; do true; done

# Yaft runs /tmp/bash by default so  creat an appropriate one and make it executable
cat >/tmp/bash <<EOF
#!/bin/ash
LD_LIBRARY_PATH=/mnt/Yaft/lib:$LD_LIBRARY_PATH PATH=/mnt/Yaft/bin:/mnt/bin:$PATH /mnt/Yaft/bin/bash
#--rcfile /mnt/Yaft/bashrc
EOF
/mnt/Yaft/bin/chmod +x /tmp/bash

# Run Yaft
cd /
/mnt/Yaft/bin/yaft </dev/tty0

# After exit, clean up
cd /
umount /root
rm /tmp/bash

# Start Carousel again
manhattan &
