summaryrefslogtreecommitdiff
path: root/user/lilo/lilo.easy-boot
blob: 0f5a802a216ae5958e728063057952bef0a5e87e (plain) (blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh -e
conf=/etc/lilo/lilo.conf

# Check whether LILO is installed
# This function is from /usr/sbin/mkboot from debianutils, with copyright:
#
#   Debian GNU/Linux
#   Copyright 1996-1997 Guy Maor <maor@debian.org>
#
# Modified for Gentoo for use with the lilo ebuild by:
#   Martin Schlemmer <azarah@gentoo.org> (16 Mar 2003)
#
# Modified for Adélie for use with the lilo APKBUILD by:
#   Max Rees <maxcrees@me.com> (19 Mar 2020)
lilocheck() {
	if ! [ -e "$conf" ]; then
		cat >&2 <<-EOF
		*
		* Could not find '$conf'!
		*
		EOF
		exit 1
	fi

	if grep -q "^[[:space:]]*password[[:space:]]*=[[:space:]]*\"\"" \
			"$conf"; then
		cat >&2 <<-EOF
		*
		* You have requested interactive LILO password setup.
		* Run "lilo -p" by hand.
		*
		EOF
		return 1
	fi

	bootpart="$(sed -n "s:^boot[ ]*=[ ]*\(.*\)[ ]*:\1:p" "$conf")"
	if ! [ -b "$bootpart" ]; then
		cat >&2 <<-EOF
		*
		* Could not find '$bootpart'!
		*
		EOF
		exit 1
	fi

	if ! dd if="$bootpart" ibs=16 count=1 2>/dev/null | grep -q LILO; then
		cat >&2 <<-EOF
		*
		* No LILO signature found on '$bootpart'.
		* You must run 'lilo' yourself.
		*
		EOF
		return 1
	fi
}

if ! [ -e /etc/fstab ]; then
	cat >&2 <<-EOF
	*
	* You are missing an /etc/fstab file, so liloconfig
	* cannot determine the root filesystem. Skipping
	* automatic configuration.
	*
	EOF
	exit 0
fi

if [ -e "$conf" ] && [ "$conf" -nt "$conf.template" ]; then
	cat >&2 <<-EOF
	*
	* You appear to have manually edited '$conf'.
	* LILO configuration will not be automatically regenerated.
	*
	EOF
	exit 0
fi

cat >&2 <<-EOF
*
* Running liloconfig...
*
EOF
liloconfig -f "$conf"
touch -r "$conf.template" "$conf"

if lilocheck; then
	cat >&2 <<-EOF
	*
	* Running lilo...
	*
	EOF
	lilo -C "$conf"
fi