3 ## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
5 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
6 ## This is free software, and you are welcome to redistribute it
7 ## under certain conditions; see COPYING for details.
14 # Exit if user has not specified a device to install
15 if [ -z "${_DEVICE}" ]
17 echo "E: Usage: ${0} DEVICE"
23 _DIRECTORY
="/boot/extlinux"
25 # Exit if user is unprivileged
26 if [ "$(id -u)" -ne 0 ]
28 echo "E: need root privileges"
32 # Exit if user has specified a non-existing device
33 if [ ! -e "${_DEVICE}" ]
35 echo "E: cannot access \"${_DEVICE}\": No such device"
39 # Exit if user has specified an invalid device
40 if [ ! -b "${_DEVICE}" ]
42 echo "E: cannot access \"${_DEVICE}\": No valid device"
46 # Checking extlinux directory
47 echo -n "P: Checking for EXTLINUX directory..."
49 # Creating extlinux directory
50 if [ ! -e "${_DIRECTORY}" ]
54 echo -n "P: Creating EXTLINUX directory..."
55 mkdir
-p "${_DIRECTORY}"
56 echo " done: ${_DIRECTORY}"
61 _MBR
="$(/sbin/blkid -s PART_ENTRY_SCHEME -p -o value ${_DEVICE})"
73 # Searching syslinux MBR
74 if [ ! -e /usr
/lib
/EXTLINUX
/${_MBR}.bin
]
76 echo "E: /usr/lib/EXTLINUX/${_MBR}.bin: No such file"
81 echo -n "P: Saving old ${_MBR}..."
82 dd if="${_DEVICE}" of=/boot/${_MBR}-$(basename "${_DEVICE}").old bs
=440 count
=1 conv
=notrunc
2> /dev
/null
83 echo " done: /boot/${_MBR}-$(basename "${_DEVICE}").old"
85 # Writing syslinux MBR
86 echo -n "P: Writing new ${_MBR}..."
87 dd if=/usr
/lib
/EXTLINUX
/${_MBR}.bin of
="${_DEVICE}" bs
=440 count
=1 conv
=notrunc
2> /dev
/null
88 echo " done: ${_DEVICE}"
90 # Writing extlinux loader
91 echo "P: Installing EXTLINUX..."
92 extlinux
--install "${_DIRECTORY}" ${@}