22 lines
787 B
Bash
22 lines
787 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
boot_dir='/boot/syslinux'
|
||
|
boot_dir="${boot_dir%/}"
|
||
|
boot_disk="$(findmnt --noheadings --target "${boot_dir}" --output 'SOURCE')" || {
|
||
|
printf -- '%s\n' \
|
||
|
'Unable to identify boot drive for '"'${boot_dir}'"' boot dir.' \
|
||
|
'Cowardly exiting. No syslinux files nor MBR were overwritten.'
|
||
|
exit 1
|
||
|
}
|
||
|
if [[ "$(<<<"${boot_dir}" wc -l)" -gt '1' ]]; then
|
||
|
printf -- '%s\n' \
|
||
|
'More than one drive mounted at '"'${boot_dir}'"' boot dir.' \
|
||
|
'Cowardly exiting. No syslinux files nor MBR were overwritten.'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
find "${boot_dir}" -type f -iname '*.c32' -delete
|
||
|
rsync -a '/usr/lib/syslinux/bios/'*'.c32' "${boot_dir}"'/'
|
||
|
extlinux --install "${boot_dir}"
|
||
|
dd bs=440 count=1 conv=notrunc if='/usr/lib/syslinux/bios/mbr.bin' of="${boot_disk}"
|