Skip to content

Commit

Permalink
mxlilo: Import into repository
Browse files Browse the repository at this point in the history
LILO is no longer used and the tools are obsolete. Import mxlilo into
repository to keep a record before removing it.

Import /usr/bin/mxlilo and /etc/lilo.conf with censored boot password.
  • Loading branch information
donald committed Sep 10, 2021
1 parent a7cc6f8 commit 202a415
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 0 deletions.
63 changes: 63 additions & 0 deletions mxlilo/lilo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@


# this config is created by mxlilo
#
# mxlilo detected the following runtime setting when last called:
#
# boot_image(lastboot) = mariux64
# boot_root(lastboot) = 801 aka /dev/sda1
# boot_init(lastboot) = /bin/systemd
# boot_rwmode(lastboot) = read-write
#

boot=/dev/sda
install=/boot/boot.b
map=/boot/map

prompt
timeout=300

#vga=extended
#bitmap=/boot/chicken.bmp
default=mariux64

password=CENSORED
restricted

lba32

read-write

root=/dev/sda1

append="init=/bin/systemd"

image=/boot/bzImage.x86_64
label=mariux64

image=/boot/bzImage.x86_64
label=donotuse
append="init=/bin/bash"
mandatory

image=/boot/bzImage-2.6.35.11.mx64.12
label=2.6.35.11-12

image=/boot/bzImage-2.6.39.mx64.14
label=2.6.39-14

image=/boot/bzImage-2.6.39.mx64.18
label=2.6.39-18

image=/boot/bzImage-3.1.9.mx64.28
label=3.1.9-28

image=/boot/bzImage-3.2.2.mx64.32
label=3.2.2-32

image=/boot/bzImage-3.2.2.mx64.34
label=3.2.2-34

image=/boot/bzImage-3.3.1.mx64.37
label=3.3.1-37

163 changes: 163 additions & 0 deletions mxlilo/mxlilo
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#!/bin/bash

set -e

liloconf=/etc/lilo.conf
mxliloconf=${liloconf}.mxlilo


options=$(beegetopt --name mxlilo \
--option noexec/no-exec/n \
-- "$@")

if [ $? -ne 0 ] ; then
echo >&2"mxlilo [-n] [image]"
exit 1
fi

eval set -- "${options}"

OPT_NOEXEC=0

while true ; do
case "$1" in
--noexec)
shift
OPT_NOEXEC=1
;;
--)
shift
break
;;
esac
done

defaultimage=$1

: ${defaultimage:=mariux64}


cmdline=( $(cat /proc/cmdline) )

boot_root=""
boot_image="mariux64"
boot_init="/bin/systemd"
boot_rwmode="read-write"
boot_ignored=""

for arg in "${cmdline[@]}" ; do
case "${arg}" in
BOOT_IMAGE=*)
boot_image=${arg##*BOOT_IMAGE=}
;;
root=*)
boot_root=${arg##*root=}
;;
init=*)
boot_init=${arg#*init=}
;;
rw)
boot_rwmode="read-write"
;;
auto)
boot_ignored="$boot_ignored ${arg}"
;;
*)
echo >&2 "WARNING: unknown cmdline argument: ${arg}"
;;
esac
done

if [ "${boot_root}" != "" ] ; then
dev_major=${boot_root:0:${#boot_root}-2}
dev_minor=${boot_root: -2}
dev_minor=${dev_minor##*0}

# only search partitions /sys/block/*/*/dev
dev_blockfile=$(egrep -l "^${dev_major}:${dev_minor}$" /sys/block/*/*/dev)
dev_blockname=${dev_blockfile%%/dev}
dev_blockname=${dev_blockname##/sys/block/}

boot_rootblockdevice=${dev_blockname##*/}
boot_bootblockdevice=${dev_blockname%%/*}
fi


conf_boot=$(grep boot= ${liloconf})
conf_root=$(grep root= ${liloconf})

conf_bootblockdevice=${conf_boot##*boot=/dev/}
conf_rootblockdevice=${conf_root##*root=/dev/}

if [ "${conf_bootblockdevice}" != "${boot_bootblockdevice}" ] ; then
echo >&2 "WARNING: configured boot device (${conf_bootblockdevice}) != booted root device (${boot_bootblockdevice})"
echo >&2 "WARNING: reusing configured boot device (boot=/dev/${conf_bootblockdevice})"
fi

bootblockdevice=${conf_bootblockdevice}

if [ "${conf_rootblockdevice}" != "${boot_rootblockdevice}" ] ; then
echo >&2 "WARNING: configured root device (${conf_rootblockdevice}) != booted root device (${boot_rootblockdevice})"
echo >&2 "WARNING: using booted root device (root=/dev/${conf_rootblockdevice})"
fi

rootblockdevice=${boot_rootblockdevice}

echo >${mxliloconf}
chmod 600 ${mxliloconf}

cat >>${mxliloconf} <<EOF
# this config is created by mxlilo
#
# mxlilo detected the following runtime setting when last called:
#
# boot_image(lastboot) = ${boot_image}
# boot_root(lastboot) = ${boot_root} aka /dev/${boot_rootblockdevice}
# boot_init(lastboot) = ${boot_init}
# boot_rwmode(lastboot) = ${boot_rwmode}
#
boot=/dev/${bootblockdevice}
install=/boot/boot.b
map=/boot/map
prompt
timeout=300
#vga=extended
#bitmap=/boot/chicken.bmp
default=${defaultimage}
password=CENSORED
restricted
lba32
${boot_rwmode}
root=/dev/${rootblockdevice}
append="init=${boot_init}"
image=/boot/bzImage.x86_64
label=mariux64
image=/boot/bzImage.x86_64
label=donotuse
append="init=/bin/bash"
mandatory
EOF

for i in $(find /boot/bzImage* -type f) ; do
label=${i##*-}
label=${label//.mx64./-}
echo "image=${i}"
echo " label=${label}"
echo
done >>${mxliloconf}

if [ "${OPT_NOEXEC}" = "0" ] ; then
exec lilo -C ${mxliloconf}
fi

0 comments on commit 202a415

Please sign in to comment.