56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
|
#!/bin/bash
|
||
|
|
||
|
function mount_efi()
|
||
|
{
|
||
|
local drive="$1"
|
||
|
local partition="$drive"1
|
||
|
if [ ! -b "$partition" ]; then
|
||
|
partition="$drive"p1
|
||
|
if [ ! -b "$partition" ]; then
|
||
|
echo "Can't find first partition for \"$drive\""
|
||
|
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
unset mnt
|
||
|
mnt="$(mktemp -d)"
|
||
|
if ! mount "$partition" "$mnt"; then
|
||
|
mkfs.vfat "$partition"
|
||
|
if ! mount "$partition" "$mnt"; then
|
||
|
echo "Can't mount \"$partition\""
|
||
|
cleanup_mnt
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function cleanup_mnt()
|
||
|
{
|
||
|
umount "$mnt"
|
||
|
flush
|
||
|
rmdir "$mnt"
|
||
|
}
|
||
|
|
||
|
function install_syslinux()
|
||
|
{
|
||
|
local drive="$1"
|
||
|
|
||
|
mount_efi "$drive"
|
||
|
|
||
|
# legacy
|
||
|
cp /usr/lib/syslinux/modules/bios/*.c32 "$mnt"/syslinux/
|
||
|
|
||
|
# UEFI
|
||
|
cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi "$mnt"/EFI/BOOT/BOOTX64.EFI
|
||
|
cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 "$mnt"/EFI/BOOT/ldlinux.e64
|
||
|
cp /usr/lib/syslinux/modules/efi64/*.c32 "$mnt"/EFI/BOOT/
|
||
|
cp syslinux/{mainmenu,syslinux}.cfg "$mnt"/syslinux
|
||
|
cp syslinux/syslx64.cfg "$mnt"/EFI/BOOT
|
||
|
|
||
|
cleanup_mnt
|
||
|
syslinux "$partition"
|
||
|
}
|
||
|
|
||
|
# vim: set ft=sh:
|