#!/bin/bash
clear
echo "
 ##############################################################################################################################
 # Provided By: The Sycorax (https://hackaday.io/hacker/1130881-the-sycorax)                                                  #
 # Date: 12/29/2020                                                                                                           #
 # Original commands posted by the user AUTUIN on 07/17/2013 (https://cassettepunk.com/large-projects/phonetendo/#comment-64) #
 #                                                                                                                            #
 # Description: A script for automatically switching over the Root Filesystem of                                              #
 # the ACN Iris 3000 to a new one that has been loaded on an SD Card.                                                         #
 ##############################################################################################################################
 "
/opt/OSDMsg 0 97
/opt/OSDMsg 0 99
echo "Stopping UI"
sed '/reboot -f/d' /release_hifi_v2ip_640X480_mx27_fs_r3/healthmon > /release_hifi_v2ip_640X480_mx27_fs_r3/healthmon2  
cp /release_hifi_v2ip_640X480_mx27_fs_r3/healthmon2 /release_hifi_v2ip_640X480_mx27_fs_r3/healthmon
rm /release_hifi_v2ip_640X480_mx27_fs_r3/healthmon2
killall veditions_mx27_ 
echo "Clearing Display"
cat /dev/zero > /dev/fb0
echo "Switching to new RootFS"
mount /proc /mnt/sd/proc -t proc
mount /sys /mnt/sd/sys -t sysfs
mkdir /mnt/sd/mnt/mtd
/sbin/pivot_root /mnt/sd /mnt/sd/mnt/mtd
cd /etc/init.d
./ssh start
mount /dev/pts
clear
cd /
exec /bin/bash
