#!/bin/bash

install_update() {
	echo -n "Inspecting Dongle for Update..."
	if [ -f /mnt/dongle/update.log ]; then
		echo "Update.log found - skipping!"
	else 
		if [ -f /mnt/dongle/update.tar ]; then
			echo "Found update - extracting"
			mkdir -p /tmp/update
			cd /tmp/update
			tar -xvf /mnt/dongle/update.tar -C /tmp/update
			#md5sum /tmp/update/stage1.sh | cut -d\  -f1
			bash /tmp/update/stage1.sh | tee /tmp/update.log
		else
			echo "No update found - continuing startup"
		fi
	fi	
	sleep 1
}

nextpi-dongle_enable

install_update

nextpi-plus_activate
  

