summaryrefslogtreecommitdiffstats
path: root/install-lilo.sh
blob: 9880c58e59285de82e91d7677a6e49770f46e4c3 (plain)
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
#!/bin/sh

set -u

main()
{
	local boot=

	[ "x$(id -u)" = 'x0' ] || error 'Must be run as the superuser'

	if [ ${#} -ne 1 ]; then
		usage >&2
		exit 1
	fi
	boot="${1}"

	[ -e "${boot}" ] || error 'Boot device not found'
	[ -e /etc/lilo.conf.in ] || \
		error '/etc/lilo.conf: No such file or directory'
	[ -e /etc/lilo.conf ] && error '/etc/lilo.conf exists'

	sed "s|@BOOT@|${boot}|g" /etc/lilo.conf.in >/etc/lilo.conf
	/sbin/lilo
	rm /etc/lilo.conf
}

usage()
{
	printf 'Usage: install-lilo <boot>\n'
}

error()
{
	local fmt="${1}"
	shift 1

	printf "install-lilo: Error: ${fmt}\n" "${@}"
	exit 2
}

main "${@}"