#!/bin/bash

readonly Script_Title="Mount Xen64_75 Kernel Headers SFS"

Filename____Kernel_Headers="kernel_sources-4.9.58-xenialpup64.sfs"
	# 10:07:53 12/22/2019.  https://distro.ibiblio.org/puppylinux/pet_packages-xenial64/


Fillepath____Kernel_Headers=""
Temp_Fillepath____Kernel_Headers_Location="/tmp/Kernel_Headers_SFS_Location.txt"

readonly Fillepath____Quickly_Toggle_SFS_Mount="/root/APSK-VBSK VirtualBox Setup Kit/Quickly Toggle SFS Mount/Caution - Running this multiple times too quickly can crash the entire system!/quickly_toggle_sfs_mount"


discdrive_num=0

while [ "$discdrive_num" -lt 4 ]
do
	let "discdrive_num++"
	
	search_results=$(find /mnt/sr$discdrive_num -type f -iname "$Filename____Kernel_Headers" | head -n 1)
	
	if [ ! -z "$search_results" ]
	then
		Fillepath____Kernel_Headers="$search_results"
	fi
done


echo "$Fillepath____Kernel_Headers" > "$Temp_Fillepath____Kernel_Headers_Location"


#sfs_load "$Fillepath____Kernel_Headers"

bash "$Fillepath____Quickly_Toggle_SFS_Mount" "$Fillepath____Kernel_Headers"