| 
						
					 | 
					 | 
					@@ -2,20 +2,31 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					boot_dir='/boot/syslinux'
 | 
					 | 
					 | 
					 | 
					boot_dir='/boot/syslinux'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					boot_dir="${boot_dir%/}"
 | 
					 | 
					 | 
					 | 
					boot_dir="${boot_dir%/}"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					boot_disk="$(findmnt --noheadings --target "${boot_dir}" --output 'SOURCE')" || {
 | 
					 | 
					 | 
					 | 
					boot_fs="$(findmnt --noheadings --target "${boot_dir}" --output 'SOURCE')" || {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf -- '%s\n' \
 | 
					 | 
					 | 
					 | 
					    printf -- '%s\n' \
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'Unable to identify boot drive for '"'${boot_dir}'"' boot dir.' \
 | 
					 | 
					 | 
					 | 
					        'Unable to identify boot drive for '"'${boot_dir}'"' boot dir.' \
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'Cowardly exiting. No syslinux files nor MBR were overwritten.'
 | 
					 | 
					 | 
					 | 
					        'Cowardly exiting. No syslinux files nor MBR were overwritten.'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    exit 1
 | 
					 | 
					 | 
					 | 
					    exit 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					if [[ "$(<<<"${boot_dir}" wc -l)" -gt '1' ]]; then
 | 
					 | 
					 | 
					 | 
					if [[ "$(<<<"${boot_fs}" wc -l)" -gt '1' ]]; then
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf -- '%s\n' \
 | 
					 | 
					 | 
					 | 
					    printf -- '%s\n' \
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'More than one drive mounted at '"'${boot_dir}'"' boot dir.' \
 | 
					 | 
					 | 
					 | 
					        'More than one drive mounted at '"'${boot_dir}'"' boot dir.' \
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'Cowardly exiting. No syslinux files nor MBR were overwritten.'
 | 
					 | 
					 | 
					 | 
					        'Cowardly exiting. No syslinux files nor MBR were overwritten.'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    exit 1
 | 
					 | 
					 | 
					 | 
					    exit 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					fi
 | 
					 | 
					 | 
					 | 
					fi
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					find "${boot_dir}" -type f -iname '*.c32' -delete
 | 
					 | 
					 | 
					 | 
					boot_fs_name="$(basename "${boot_fs}")"
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					rsync -a '/usr/lib/syslinux/bios/'*'.c32' "${boot_dir}"'/'
 | 
					 | 
					 | 
					 | 
					boot_disk="$(lsblk --output 'NAME' --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select(.children[].name=="'"${boot_fs_name}"'") | .name')"
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					extlinux --install "${boot_dir}"
 | 
					 | 
					 | 
					 | 
					if [[ ! "${boot_disk}" ]]; then
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					dd bs=440 count=1 conv=notrunc if='/usr/lib/syslinux/bios/mbr.bin' of="${boot_disk}"
 | 
					 | 
					 | 
					 | 
					    # There's no parent drive over "${boot_fs}" meaning "${boot_fs}" itself
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    # already is the parent. This is a file system on a drive and not on a
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    # partition.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    boot_disk="${boot_fs}"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					else
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    boot_disk='/dev/'"${boot_disk}"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					fi
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					find "${boot_dir}" -type f -iname '*.c32' -delete && echo 'Delete old COMBOOT files from boot drive'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					rsync -a '/usr/lib/syslinux/bios/'*'.c32' "${boot_dir}"'/' && echo 'Put new COMBOOT files onto boot drive'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					extlinux --install "${boot_dir}" &>/dev/null && echo 'Install new extlinux boot loader'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					dd bs=440 count=1 conv=notrunc if='/usr/lib/syslinux/bios/mbr.bin' of="${boot_disk}" 2>/dev/null && echo 'Overwrite MBR with newest version'
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						 
						
						
						
						 
					 | 
					 | 
					 
 |