#!/bin/sh set -u main() { local boot= [ "x$(id -u)" = 'x0' ] || error 'Must be run as the superuser' if [ ${#} -ne 2 ]; then usage >&2 exit 1 fi boot="${1}" root="${2}" [ -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; s|@ROOT@|${root}|g;" /etc/lilo.conf.in \ >/etc/lilo.conf /sbin/lilo rm /etc/lilo.conf } usage() { printf 'Usage: install-lilo \n' } error() { local fmt="${1}" shift 1 printf "install-lilo: Error: ${fmt}\n" "${@}" exit 2 } main "${@}"