7 # Exit if user has not specified a device to install
10 echo "E: Usage: ${0} DEVICE"
16 _DIRECTORY
="/boot/extlinux"
18 # Exit if user is unprivileged
19 if [ "$(id -u)" -ne 0 ]
21 echo "E: need root privileges"
25 # Exit if user has specified a non-existing device
26 if [ ! -e "${_DEVICE}" ]
28 echo "E: cannot access \"${_DEVICE}\": No such device"
32 # Exit if user has specified an invalid device
33 if [ ! -b "${_DEVICE}" ]
35 echo "E: cannot access \"${_DEVICE}\": No valid device"
39 # Checking extlinux directory
40 echo -n "P: Checking for EXTLINUX directory..."
42 # Creating extlinux directory
43 if [ ! -e "${_DIRECTORY}" ]
47 echo -n "P: Creating EXTLINUX directory..."
48 mkdir
-p "${_DIRECTORY}"
49 echo " done: ${_DIRECTORY}"
54 # Searching syslinux MBR
55 if [ ! -e /usr
/lib
/extlinux
/mbr.bin
]
57 echo "E: /usr/lib/extlinux/mbr.bin: No such file"
62 echo -n "P: Saving old MBR..."
63 dd if="${_DEVICE}" of
=/boot
/mbr-$
(basename "${_DEVICE}").old bs
=440 count
=1 2> /dev
/null
64 echo " done: /boot/mbr-$(basename "${_DEVICE}").old"
66 # Writing syslinux MBR
67 echo -n "P: Writing new MBR..."
68 dd if=/usr
/lib
/extlinux
/mbr.bin of
="${_DEVICE}" bs
=440 count
=1 2> /dev
/null
69 echo " done: ${_DEVICE}"
71 # Writing extlinux loader
72 echo "P: Installing EXTLINUX..."
73 extlinux
--install "${_DIRECTORY}" ${@}