legacy_grub_2013 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #! /bin/bash
  2. # rcrsn51 2013-03-14
  3. export TEXTDOMAIN=legacy_grub_2013
  4. export OUTPUT_CHARSET=UTF-8
  5. INSTALL () {
  6. # $1=stage1 $2=partition $3=stage2 $4=windows $5=Ubuntu $6:true=frugal,false=full
  7. TIMEOUT=2
  8. [ -n "$4" -o -n "$5" ] && TIMEOUT=10
  9. mount /dev/$2 /mnt/data
  10. if [ $? -gt 0 ]; then
  11. Xdialog --title " " --msgbox "$(gettext 'Cannot mount') $2" 0 0
  12. exit
  13. fi
  14. GRUBPATH="/mnt/data/boot/grub"
  15. mkdir -p $GRUBPATH
  16. if [ $? -gt 0 ]; then
  17. Xdialog --title " " --msgbox "$(gettext 'Cannot create') $GRUBPATH" 0 0
  18. exit
  19. fi
  20. cp $(find /usr/lib/grub -name stage1) $GRUBPATH
  21. cp $(find /usr/lib/grub -name stage2) $GRUBPATH
  22. grub --batch --no-floppy << EOF
  23. root $3
  24. setup $1
  25. quit
  26. EOF
  27. [ -f $GRUBPATH/menu.lst ] && mv $GRUBPATH/menu.lst $GRUBPATH/menu.lst.000
  28. cat > $GRUBPATH/menu.lst << EOF
  29. timeout $TIMEOUT
  30. default 0
  31. #
  32. EOF
  33. if [ "$6" = "true" ]; then
  34. cat >> $GRUBPATH/menu.lst << EOF
  35. title Puppy Linux Frugal on $2
  36. root $3
  37. kernel /vmlinuz pmedia=atahd pdev1=$2 pfix=fsck
  38. initrd /initrd.gz
  39. EOF
  40. else
  41. cat >> $GRUBPATH/menu.lst << EOF
  42. title Puppy Linux Full on $2
  43. root $3
  44. kernel /boot/vmlinuz root=/dev/$2 ro vga=normal
  45. EOF
  46. fi
  47. if [ -n "$4" ]; then
  48. cat >> $GRUBPATH/menu.lst << EOF
  49. #
  50. title Windows on $4
  51. root $4
  52. chainloader +1
  53. EOF
  54. fi
  55. if [ -n "$5" ]; then
  56. cat >> $GRUBPATH/menu.lst << EOF
  57. #
  58. title Ubuntu on $5
  59. root $5
  60. kernel /boot/grub/core.img
  61. EOF
  62. fi
  63. sync
  64. umount /mnt/data
  65. }
  66. ############### end of functions #############
  67. export Grub_config='
  68. <window title="Legacy GRUB Config 2013" icon-name="gtk-preferences">
  69. <vbox space-expand="true" space-fill="true">
  70. '"`/usr/lib/gtkdialog/xml_info fixed "startup_os.svg" 60 "$(gettext 'Legacy GRUB has two parts. Stage1 is the bootloader code. It can be installed in the MBR of a hard drive or in a partition boot sector. Stage2 is the set of support files, like menu.lst. It is installed in the folder /boot/grub of a partition. Legacy GRUB works with ext or FAT filesystems, but not NTFS.')"`"'
  71. <notebook labels="'$(gettext 'Quick mode')'|'$(gettext 'Expert mode')'" space-expand="true" space-fill="true">
  72. <vbox space-expand="true" space-fill="true">
  73. <frame '$(gettext 'Quick mode')'>
  74. <hbox space-expand="true" space-fill="true">
  75. <text xalign="0" yalign="0" space-expand="true" space-fill="true">
  76. <label>"'$(gettext 'Install Stage1 in the MBR of Drive sda
  77. and Stage2 in sda1')'"</label>
  78. </text>
  79. <vbox space-expand="false" space-fill="false">
  80. <text xalign="0"><label>'$(gettext 'Puppy Setup')'</label></text>
  81. <radiobutton>
  82. <variable>QFRUG</variable>
  83. <label>'$(gettext 'Frugal')'</label>
  84. </radiobutton>
  85. <radiobutton>
  86. <variable>QFULL</variable>
  87. <label>'$(gettext 'Full')'</label>
  88. </radiobutton>
  89. <text space-expand="true" space-fill="true"><label>""</label></text>
  90. <button image-position="2">
  91. <label>" '$(gettext 'Quick Install')' "</label>
  92. '"`/usr/lib/gtkdialog/xml_button-icon install.svg big`"'
  93. </button>
  94. </vbox>
  95. </hbox>
  96. </frame>
  97. </vbox>
  98. <vbox space-expand="true" space-fill="true">
  99. <frame '$(gettext 'Expert mode')'>
  100. <hbox space-expand="true" space-fill="true">
  101. <vbox space-expand="false" space-fill="false">
  102. <hbox>
  103. <entry width-request="70" space-expand="false" space-fill="false">
  104. <variable>STAGE1</variable>
  105. <default>(hd0)</default>
  106. </entry>
  107. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Target for Stage1')'</label></text>
  108. </hbox>
  109. <hbox>
  110. <entry width-request="70" space-expand="false" space-fill="false">
  111. <variable>PART</variable>
  112. <default>sda1</default>
  113. </entry>
  114. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Partition for Stage2')'</label></text>
  115. </hbox>
  116. <hbox>
  117. <entry width-request="70" space-expand="false" space-fill="false">
  118. <variable>STAGE2</variable>
  119. <default>(hd0,0)</default>
  120. </entry>
  121. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Target for Stage2')'</label></text>
  122. </hbox>
  123. <hbox>
  124. <entry width-request="70" space-expand="false" space-fill="false">
  125. <variable>WIN</variable>
  126. <default>(hd0,0)</default>
  127. </entry>
  128. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Optional Windows entry')'</label></text>
  129. </hbox>
  130. <hbox>
  131. <entry width-request="70" space-expand="false" space-fill="false">
  132. <variable>UBUNTU</variable>
  133. <default>(hd0,0)</default>
  134. </entry>
  135. <text xalign="0" space-expand="true" space-fill="true"><label>'$(gettext 'Optional Ubuntu entry')'</label></text>
  136. </hbox>
  137. </vbox>
  138. <text space-expand="true" space-fill="true"><label>""</label></text>
  139. <vbox space-expand="false" space-fill="false">
  140. <text xalign="0"><label>'$(gettext 'Puppy Setup')'</label></text>
  141. <radiobutton>
  142. <variable>EFRUG</variable>
  143. <label>'$(gettext 'Frugal')'</label>
  144. </radiobutton>
  145. <radiobutton>
  146. <variable>EFULL</variable>
  147. <label>'$(gettext 'Full')'</label>
  148. </radiobutton>
  149. <text space-expand="true" space-fill="true"><label>""</label></text>
  150. <button image-position="2">
  151. <label>" '$(gettext 'Expert Install')' "</label>
  152. '"`/usr/lib/gtkdialog/xml_button-icon install_options.svg big`"'
  153. </button>
  154. </vbox>
  155. </hbox>
  156. </frame>
  157. </vbox>
  158. </notebook>
  159. <hbox space-expand="false" space-fill="false">
  160. <button space-expand="false" space-fill="false">
  161. '"`/usr/lib/gtkdialog/xml_button-icon help_online.svg`"'
  162. <label>'$(gettext 'Help')'</label>
  163. </button>
  164. <text space-expand="true" space-fill="true"><label>""</label></text>
  165. <button space-expand="false" space-fill="false">
  166. '"`/usr/lib/gtkdialog/xml_button-icon cancel`"'
  167. <label>'$(gettext 'Cancel')'</label>
  168. </button>
  169. </hbox>
  170. </vbox>
  171. </window>'
  172. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  173. I=$IFS; IFS=""
  174. for STATEMENTS in $(gtkdialog -p Grub_config); do
  175. eval $STATEMENTS
  176. done
  177. IFS=$I
  178. [ "$EXIT" = "$(gettext 'Cancel')" -o "$EXIT" = "abort" ] && exit
  179. [ "$EXIT" = "$(gettext 'Help')" ] && exec defaultbrowser http://murga-linux.com/puppy/viewtopic.php?p=692147#692147
  180. Xdialog --title " " --yesno "$(gettext 'Do you really want to install GRUB?')" 0 0
  181. [ $? -gt 0 ] && exit
  182. if [ "$EXIT" = "$(gettext 'Quick Install')" ]; then #quick install
  183. INSTALL "(hd0)" "sda1" "(hd0,0)" "" "" "$QFRUG" #true=frugal, false=full
  184. else #expert install
  185. INSTALL "$STAGE1" "$PART" "$STAGE2" "$WIN" "$UBUNTU" "$EFRUG" #true=frugal, false=full
  186. fi
  187. /usr/lib/gtkdialog/box_ok "Legacy GRUB Config 2013" complete "<b>$(gettext 'Done')</b>"