summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-06-27 15:37:38 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-06-27 15:37:38 (EDT)
commitdc42d102a80efd22d24073d170a6514f26793c47 (patch)
tree6935e0e5879e3b0585167e6b2f2f28871e419205
parent2b0fc4ca23b07b6b911a3d0ce2257113b77921e9 (diff)
install-lilo.sh: New file.
-rw-r--r--install-lilo.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/install-lilo.sh b/install-lilo.sh
new file mode 100644
index 0000000..3ce2a16
--- /dev/null
+++ b/install-lilo.sh
@@ -0,0 +1,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 "${@}"