File: extlinux-install

package info (click to toggle)
syslinux 2%3A4.02%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 23,804 kB
  • ctags: 71,027
  • sloc: ansic: 270,621; pascal: 9,631; asm: 9,089; perl: 3,492; makefile: 1,588; sh: 511; python: 266; xml: 39
file content (72 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh

set -e

_DEVICE="${1}"
shift

_DIRECTORY="/boot/extlinux"

# Exit if user is unprivileged
if [ "$(id -u)" -ne 0 ]
then
	echo "E: need root privileges"
	exit 1
fi

# Exit if user has not specified a device to install
if [ -z "${_DEVICE}" ]
then
	echo "E: Usage: ${0} DEVICE"
	exit 1
fi

# Exit if user has specified a non-existing device
if [ ! -e "${_DEVICE}" ]
then
	echo "E: cannot access \"${_DEVICE}\": No such device"
	exit 1
fi

# Exit if user has specified an invalid device
if [ ! -b "${_DEVICE}" ]
then
	echo "E: cannot access \"${_DEVICE}\": No valid device"
	exit 1
fi

# Checking extlinux directory
echo -n "P: Checking for EXTLINUX directory..."

# Creating extlinux directory
if [ ! -e "${_DIRECTORY}" ]
then
	echo " not found."

	echo -n "P: Creating EXTLINUX directory..."
	mkdir -p "${_DIRECTORY}"
	echo " done: ${_DIRECTORY}"
else
	echo " found."
fi

# Searching syslinux MBR
if [ ! -e /usr/lib/extlinux/mbr.bin ]
then
	echo "E: /usr/lib/extlinux/mbr.bin: No such file"
	exit 1
fi

# Saving old MBR
echo -n "P: Saving old MBR..."
dd if="${_DEVICE}" of=/boot/mbr-$(basename "${_DEVICE}").old bs=466 count=1 2> /dev/null
echo " done: /boot/mbr-$(basename "${_DEVICE}").old"

# Writing syslinux MBR
echo -n "P: Writing new MBR..."
dd if=/usr/lib/extlinux/mbr.bin of="${_DEVICE}" bs=466 count=1 2> /dev/null
echo " done: ${_DEVICE}"

# Writing extlinux loader
echo "P: Installing EXTLINUX..."
extlinux --install "${_DIRECTORY}" ${@}