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.

112 lines
2.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../syslinux/stone_mod_extlinux.sh
  5. # Copyright (C) 2006 - 2008 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 extlinux extlinux (syslinux) Boot Loader Setup
  18. # [SETUP] 90 extlinux
  19. rootdev_cache=
  20. bootdev_cache=
  21. bootdrive_cache=
  22. rootdev()
  23. {
  24. [ -n "$rootdev_cache" ] || rootdev_cache=$(
  25. grep '^/dev/.* / ' /proc/mounts |
  26. head -n 1 | cut -d' ' -f1 )
  27. echo "$rootdev_cache"
  28. }
  29. bootdev()
  30. {
  31. [ -n "$bootdev_cache" ] || bootdev_cache=$(
  32. grep '^/dev/.* /boot ' /proc/mounts |
  33. head -n 1 | cut -d' ' -f1 )
  34. [ -n "$bootdev_cache" ] || bootdev_cache=$( rootdev )
  35. echo "$bootdev_cache"
  36. }
  37. bootdrive()
  38. {
  39. [ -n "$bootdrive_cache" ] || bootdrive_cache=$(
  40. bootdev | sed -r 's/p?[0-9]*$//' )
  41. echo "$bootdrive_cache"
  42. }
  43. extlinux_kernel_list()
  44. {
  45. local label= first=1 initrd= x=
  46. for x in `(cd /boot/ ; ls -1 vmlinuz_* ) | sort -r` ; do
  47. if [ $first = 1 ] ; then
  48. label=linux ; first=0
  49. else
  50. label=linux-${x/vmlinuz_/}
  51. label=${label/-dist/}
  52. fi
  53. initrd=initrd-${x/vmlinuz_/}.img
  54. cat <<-EOT
  55. LABEL $label
  56. KERNEL /$x
  57. APPEND initrd=/$initrd root=$( rootdev ) ro
  58. EOT
  59. done
  60. }
  61. extlinux_create_conf()
  62. {
  63. mkdir -p $extlinuxdir
  64. cat > $extlinuxconf <<-EOT
  65. DEFAULT linux
  66. PROMPT 1
  67. TIMEOUT 300
  68. EOT
  69. extlinux_kernel_list >> $extlinuxconf
  70. gui_message "This is the new $extlinuxconf file:
  71. $( cat $extlinuxconf )"
  72. }
  73. extlinux_install()
  74. {
  75. gui_cmd "Installing extlinux in $extlinuxdir" \
  76. "mkdir -p $extlinuxdir; extlinux -i $extlinuxdir"
  77. }
  78. extlinux_clean_mbr()
  79. {
  80. cat /usr/share/syslinux/mbr.bin > "$1"
  81. }
  82. main()
  83. {
  84. local extlinuxdir=/boot/extlinux
  85. local extlinuxconf=$extlinuxdir/extlinux.conf
  86. local drive=$( bootdrive )
  87. while gui_menu extlinux 'Extlinux (syslinux) Boot Loader Setup' \
  88. '(Re-)Create extlinux.conf with installed kernels' 'extlinux_create_conf' \
  89. "(Re-)Install extlinux in $extlinuxdir" 'extlinux_install' \
  90. "Clean $drive's MBR (use with care)" "extlinux_clean_mbr '$drive'" \
  91. "Edit $extlinuxconf (recommended)" \
  92. "gui_edit 'Extlinux Config File' $extlinuxconf"
  93. do : ; done
  94. }