OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../lilo/stone_mod_lilo.sh
  5. # Copyright (C) 2006 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. # Copyright (C) 1998 - 2003 Clifford Wolf
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. #
  17. # [MAIN] 70 lilo LILO Boot Loader Setup
  18. # [SETUP] 90 lilo
  19. create_kernel_list() {
  20. local label= first=1 initrd=
  21. first=1
  22. for x in `(cd /boot/ ; ls vmlinuz_* ) | sort -r` ; do
  23. if [ $first = 1 ] ; then
  24. label=linux ; first=0
  25. else
  26. label=linux-${x/vmlinuz_/}
  27. label=${label/-dist/}
  28. fi
  29. initrd=initrd-${x/vmlinuz_/}.img
  30. cat << EOT
  31. image=/boot/$x
  32. label=$label
  33. append="root=$rootdev"
  34. initrd=/boot/$initrd
  35. read-only
  36. EOT
  37. done
  38. }
  39. create_lilo_conf() {
  40. i=0 ; rootdev="`grep ' / ' /proc/mounts | tail -n 1 | \
  41. awk '/\/dev\// { print $1; }'`"
  42. rootdev="$( cd ${rootdev%/*} ; pwd -P )/${rootdev##*/}"
  43. # TODO: readlink? //mnemoc
  44. while [ -L $rootdev ] ; do
  45. directory="$( cd `dirname $rootdev` ; pwd -P )"
  46. rootdev="$( ls -l $rootdev | sed 's,.* -> ,,' )"
  47. [ "${rootdev##/*}" ] && rootdev="$directory/$rootdev"
  48. i=$(( $i + 1 )) ; [ $i -gt 20 ] && rootdev="Not found!"
  49. done
  50. bootdev="`echo $rootdev | sed -e 's,[0-9]*$,,'`"
  51. cat << EOT > /etc/lilo.conf
  52. boot=$bootdev
  53. delay=40
  54. timeout=60
  55. prompt
  56. lba32
  57. EOT
  58. create_kernel_list >> /etc/lilo.conf
  59. cat << EOT >> /etc/lilo.conf
  60. image=/boot/memtest86.bin
  61. label=memtest
  62. optional
  63. EOT
  64. gui_message "This is the new /etc/lilo.conf file:
  65. $( cat /etc/lilo.conf )"
  66. }
  67. main() {
  68. if [ ! -f /etc/lilo.conf ] ; then
  69. if gui_yesno "LILO does not appear to be configured.
  70. Automatically install LILO now?"; then
  71. create_lilo_conf
  72. if ! gui_cmd "Installing LILO in MBR" "lilo -v" ; then
  73. gui_message "There was an error while installing LILO."
  74. fi
  75. fi
  76. fi
  77. while
  78. gui_menu lilo 'LILO Boot Loader Setup' \
  79. '(Re-)Create lilo.conf with installed kernels' 'create_lilo_conf' \
  80. '(Re-)Install LILO in MBR of /dev/discs/disc0/disc' \
  81. 'gui_cmd "Installing LILO in MBR" "lilo -v"' \
  82. "Edit /etc/lilo.conf (recommended before installing LILO)" \
  83. "gui_edit 'LILO Config File' /etc/lilo.conf"
  84. do : ; done
  85. }