Using linux keyword for linux kernel images to profit from syslinux' automagic (Close...
[syslinux-debian/hramrach.git] / debian / local / extlinux-install
blob007d5a4349d198c913a4dc0a9bf0dfce4f123984
1 #!/bin/sh
3 set -e
5 _DEVICE="${1}"
7 # Exit if user has not specified a device to install
8 if [ -z "${_DEVICE}" ]
9 then
10 echo "E: Usage: ${0} DEVICE"
11 exit 1
12 else
13 shift
16 _DIRECTORY="/boot/extlinux"
18 # Exit if user is unprivileged
19 if [ "$(id -u)" -ne 0 ]
20 then
21 echo "E: need root privileges"
22 exit 1
25 # Exit if user has specified a non-existing device
26 if [ ! -e "${_DEVICE}" ]
27 then
28 echo "E: cannot access \"${_DEVICE}\": No such device"
29 exit 1
32 # Exit if user has specified an invalid device
33 if [ ! -b "${_DEVICE}" ]
34 then
35 echo "E: cannot access \"${_DEVICE}\": No valid device"
36 exit 1
39 # Checking extlinux directory
40 echo -n "P: Checking for EXTLINUX directory..."
42 # Creating extlinux directory
43 if [ ! -e "${_DIRECTORY}" ]
44 then
45 echo " not found."
47 echo -n "P: Creating EXTLINUX directory..."
48 mkdir -p "${_DIRECTORY}"
49 echo " done: ${_DIRECTORY}"
50 else
51 echo " found."
54 # Searching syslinux MBR
55 if [ ! -e /usr/lib/extlinux/mbr.bin ]
56 then
57 echo "E: /usr/lib/extlinux/mbr.bin: No such file"
58 exit 1
61 # Saving old MBR
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}" ${@}