| 1 | #!/bin/bash |
|---|
| 2 | # Author: Steven Shiau <steven _at_ nchc org tw> |
|---|
| 3 | # License: GPL |
|---|
| 4 | # Description: This program will put a syslinux.cfg or isolinux.cfg in target directory, which is used to boot clonezilla live. |
|---|
| 5 | |
|---|
| 6 | # Load DRBL setting and functions |
|---|
| 7 | if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then |
|---|
| 8 | echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!" |
|---|
| 9 | exit 1 |
|---|
| 10 | fi |
|---|
| 11 | . /opt/drbl/sbin/drbl-conf-functions |
|---|
| 12 | |
|---|
| 13 | # Load some necessary setting from drbl-ocs.conf |
|---|
| 14 | . /opt/drbl/conf/drbl-ocs.conf |
|---|
| 15 | |
|---|
| 16 | # setting |
|---|
| 17 | KERNEL_FILE_DEFAULT="live/$kernel_file" |
|---|
| 18 | INITRD_FILE_DEFAULT="live/$initrd_file" |
|---|
| 19 | # default time (Unit: 1/10 secs) |
|---|
| 20 | TIMEOUT_DEF="300" |
|---|
| 21 | # Grub config |
|---|
| 22 | # root default is (hd0,0), root for Linux in bootparam is default as /dev/sda1 (root=/dev/sda1) |
|---|
| 23 | OP_HD_DEV_GRUB_DEF="hd0" |
|---|
| 24 | OP_PART_NO_GRUB_DEF="0" |
|---|
| 25 | OUTPUT_DEV_GRUB_DEF="/dev/sdb1" |
|---|
| 26 | OUTPUT_TITLE_DEF="Koha live" |
|---|
| 27 | GPARTED_LIVE_MAINTAINER="Steven Shiau" |
|---|
| 28 | # ocs_logo_img_syslinux is loaded from drbl.conf |
|---|
| 29 | BGIMG_FILE_DEF="$ocs_logo_img_syslinux" |
|---|
| 30 | |
|---|
| 31 | # |
|---|
| 32 | prog="$(basename $0)" |
|---|
| 33 | |
|---|
| 34 | # functions |
|---|
| 35 | USAGE() { |
|---|
| 36 | echo "Usage:" |
|---|
| 37 | echo "To create syslinux or isolinux menu for clonezilla live:" |
|---|
| 38 | echo "$prog [OPTION] [isolinux|syslinux|grub] OUTPUT-DIR" |
|---|
| 39 | echo "OPTION:" |
|---|
| 40 | language_help_prompt_by_idx_no |
|---|
| 41 | echo "-b, --bg-mode [text|graphic] Assign the back ground of boot menu. Default is graphic" |
|---|
| 42 | echo "-f, --framebuffer-mode VGA_MODE Assign the framebuffer mode as VGA_MODE, for example, 788 is resolution 800x600 with 16 bpp." |
|---|
| 43 | echo "-k, --kernel-file FILENAME Provide the kernel name, which wiil be used in the menu.lst or syslinux.cfg. If unset, $KERNEL_FILE_DEFAULT will be used" |
|---|
| 44 | echo "-i, --initrd-file FILENAME Provide the initrd name, which wiil be used in the menu.lst or syslinux.cfg. If unset, $INITRD_FILE_DEFAULT will be used" |
|---|
| 45 | echo "-n, --version-no VER_no Provide the version number to be shown in the syslinux/isolinux boot menu." |
|---|
| 46 | echo "-p, --boot-param PARAM Provide the append strings for kernel bootparam. which wiil be used in the menu.lst or syslinux.cfg. If unset, $BOOT_PARAM_DEFAULT will be used. Note! For clonezilla live (based on Debian Live), boot=casper or boot=live is a must, so do not forget to include it." |
|---|
| 47 | echo "-g1, grub-hd-dev DEV Assign grub root device DEV (Ex: hd0)" |
|---|
| 48 | echo "-g2, grub-part-no NO Assign grub root partition number index NO (Ex: 0)" |
|---|
| 49 | echo "-g3, OS-root-dev ROOTDEV Assign ROOTDEV which grub will pass as boot param (Ex. /dev/sda1)" |
|---|
| 50 | echo "-s, --show-only-one-vga Show only one default VGA mode. By default, we will show 2 modes (800x600 and 640x480). If this is set, only 800x600 will be shown." |
|---|
| 51 | echo "-t, --timeout TIME Assign TIME*0.1 secs for timeout when booting." |
|---|
| 52 | echo "-e, --title TITLE Assign boot menu title (Clonezilla live, DRBL/Clonezilla server live...), default is 'Clonezilla live'." |
|---|
| 53 | echo "-m, --bgimg IMG Assign boot menu title background as IMG file (absolute file, 640x480 image.)" |
|---|
| 54 | echo "-z, --add-lang-menu LANG Add locale LANG menu in boot menu" |
|---|
| 55 | echo "Ex:" |
|---|
| 56 | echo "To create a isolinux menu in dir isolinux_tmp/isolinux/" |
|---|
| 57 | echo "$prog isolinux isolinux_tmp/isolinux/" |
|---|
| 58 | echo "To create a grub menu in dir grub_tmp/boot/grub/" |
|---|
| 59 | echo "$prog grub grub_tmp/boot/grub/" |
|---|
| 60 | } |
|---|
| 61 | gen_config_syslinux() { |
|---|
| 62 | local type=$1 |
|---|
| 63 | case "$type" in |
|---|
| 64 | isolinux) output_file="$output_dir/isolinux.cfg" ;; |
|---|
| 65 | syslinux) output_file="$output_dir/syslinux.cfg" ;; |
|---|
| 66 | esac |
|---|
| 67 | bg_img="$(basename $bgimg_file)" |
|---|
| 68 | echo "Adding $type menus for $output_title..." |
|---|
| 69 | cat <<-BOOT_MENU_END > $output_file |
|---|
| 70 | # Created by generate-pxe-menu! Do NOT edit unless you know what you are doing! |
|---|
| 71 | # Keep those comment "MENU DEFAULT" and "MENU HIDE"! Do NOT remove them. |
|---|
| 72 | # Note!!! If "serial" directive exists, it must be the first directive |
|---|
| 73 | default $MENUC32 |
|---|
| 74 | timeout $timeout |
|---|
| 75 | prompt 0 |
|---|
| 76 | noescape 1 |
|---|
| 77 | MENU MARGIN 5 |
|---|
| 78 | $mask MENU BACKGROUND $bg_img |
|---|
| 79 | # Set the color for unselected menu item and timout message |
|---|
| 80 | $mask MENU COLOR UNSEL 7;32;41 #c0000090 #00000000 |
|---|
| 81 | $mask MENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000 |
|---|
| 82 | $mask MENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000 |
|---|
| 83 | $mask MENU COLOR HELP 7;32;41 #c0000090 #00000000 |
|---|
| 84 | |
|---|
| 85 | # MENU MASTER PASSWD |
|---|
| 86 | |
|---|
| 87 | say ********************************************************************** |
|---|
| 88 | say $boot_menu_txt_say_pkg |
|---|
| 89 | say $boot_menu_txt_say_org |
|---|
| 90 | say $project_url |
|---|
| 91 | say THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! |
|---|
| 92 | say ********************************************************************** |
|---|
| 93 | |
|---|
| 94 | # Allow client to edit the parameters |
|---|
| 95 | ALLOWOPTIONS 1 |
|---|
| 96 | |
|---|
| 97 | # simple menu title |
|---|
| 98 | MENU TITLE $project_url |
|---|
| 99 | |
|---|
| 100 | # since no network setting in the squashfs image, therefore if ip=frommedia, the network is disabled. |
|---|
| 101 | label $output_title |
|---|
| 102 | MENU DEFAULT |
|---|
| 103 | # MENU HIDE |
|---|
| 104 | MENU LABEL $output_title (Default settings$vga_800_600_prompt) |
|---|
| 105 | # MENU PASSWD |
|---|
| 106 | kernel $kernel_file |
|---|
| 107 | append initrd=$initrd_file $boot_param vga=$vga_mode |
|---|
| 108 | TEXT HELP |
|---|
| 109 | $boot_menu_pkg_ver_cpright |
|---|
| 110 | $boot_menu_pkg_disclaimer |
|---|
| 111 | ENDTEXT |
|---|
| 112 | |
|---|
| 113 | BOOT_MENU_END |
|---|
| 114 | if [ "$show_vga_mode" = "2" ]; then |
|---|
| 115 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 116 | label $output_title 640x640 |
|---|
| 117 | # MENU DEFAULT |
|---|
| 118 | # MENU HIDE |
|---|
| 119 | MENU LABEL $output_title (Default settings, VGA 640x480) |
|---|
| 120 | # MENU PASSWD |
|---|
| 121 | kernel $kernel_file |
|---|
| 122 | append initrd=$initrd_file $boot_param vga=785 |
|---|
| 123 | TEXT HELP |
|---|
| 124 | VGA mode 640x480. OK for most of VGA cards, Choose this |
|---|
| 125 | if this is an Asus Eee PC |
|---|
| 126 | ENDTEXT |
|---|
| 127 | |
|---|
| 128 | BOOT_MENU_END |
|---|
| 129 | fi |
|---|
| 130 | |
|---|
| 131 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 132 | label $output_title (To RAM) |
|---|
| 133 | # MENU DEFAULT |
|---|
| 134 | # MENU HIDE |
|---|
| 135 | MENU LABEL $output_title (To RAM. Boot media can be removed later) |
|---|
| 136 | # MENU PASSWD |
|---|
| 137 | kernel $kernel_file |
|---|
| 138 | append initrd=$initrd_file $boot_param vga=$vga_mode toram |
|---|
| 139 | TEXT HELP |
|---|
| 140 | All the programs will be copied to RAM, so you can |
|---|
| 141 | remove boot media (CD or USB flash drive) later |
|---|
| 142 | ENDTEXT |
|---|
| 143 | |
|---|
| 144 | BOOT_MENU_END |
|---|
| 145 | |
|---|
| 146 | if [ -n "$lang_locale" ]; then |
|---|
| 147 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 148 | label $output_title ($lang_locale) |
|---|
| 149 | # MENU DEFAULT |
|---|
| 150 | # MENU HIDE |
|---|
| 151 | MENU LABEL $output_title ($lang_locale, default settings$vga_800_600_prompt) |
|---|
| 152 | # MENU PASSWD |
|---|
| 153 | kernel $kernel_file |
|---|
| 154 | append initrd=$initrd_file $boot_param vga=$vga_mode locale=$lang_locale |
|---|
| 155 | TEXT HELP |
|---|
| 156 | $lang_locale, and VGA mode 800x600 |
|---|
| 157 | ENDTEXT |
|---|
| 158 | |
|---|
| 159 | BOOT_MENU_END |
|---|
| 160 | if [ "$show_vga_mode" = "2" ]; then |
|---|
| 161 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 162 | label $output_title ($lang_locale) 640x480 |
|---|
| 163 | # MENU DEFAULT |
|---|
| 164 | # MENU HIDE |
|---|
| 165 | MENU LABEL $output_title ($lang_locale, default settings, VGA 640x480) |
|---|
| 166 | # MENU PASSWD |
|---|
| 167 | kernel $kernel_file |
|---|
| 168 | append initrd=$initrd_file $boot_param vga=785 locale=$lang_locale |
|---|
| 169 | TEXT HELP |
|---|
| 170 | $lang_locale, and VGA mode 640x480. OK for most of VGA cards, |
|---|
| 171 | Choose this if this is an Asus Eee PC |
|---|
| 172 | ENDTEXT |
|---|
| 173 | |
|---|
| 174 | BOOT_MENU_END |
|---|
| 175 | fi |
|---|
| 176 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 177 | label $output_title ($lang_locale, to RAM) |
|---|
| 178 | # MENU DEFAULT |
|---|
| 179 | # MENU HIDE |
|---|
| 180 | MENU LABEL $output_title ($lang_locale. To RAM. Boot media can be removed later) |
|---|
| 181 | # MENU PASSWD |
|---|
| 182 | kernel $kernel_file |
|---|
| 183 | append initrd=$initrd_file $boot_param vga=$vga_mode locale=$lang_locale toram |
|---|
| 184 | TEXT HELP |
|---|
| 185 | $lang_locale, and alll the programs will be copied to RAM, |
|---|
| 186 | so you can remove boot media (CD or USB flash drive) later |
|---|
| 187 | ENDTEXT |
|---|
| 188 | |
|---|
| 189 | BOOT_MENU_END |
|---|
| 190 | fi |
|---|
| 191 | |
|---|
| 192 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 193 | label $output_title without framebuffer |
|---|
| 194 | # MENU DEFAULT |
|---|
| 195 | # MENU HIDE |
|---|
| 196 | MENU LABEL $output_title (Safe graphic settings, vga=normal) |
|---|
| 197 | # MENU PASSWD |
|---|
| 198 | kernel $kernel_file |
|---|
| 199 | append initrd=$initrd_file $boot_param vga=normal |
|---|
| 200 | TEXT HELP |
|---|
| 201 | Disable console frame buffer support |
|---|
| 202 | ENDTEXT |
|---|
| 203 | |
|---|
| 204 | label $output_title failsafe mode |
|---|
| 205 | # MENU DEFAULT |
|---|
| 206 | # MENU HIDE |
|---|
| 207 | MENU LABEL $output_title (Failsafe mode) |
|---|
| 208 | # MENU PASSWD |
|---|
| 209 | kernel $kernel_file |
|---|
| 210 | append initrd=$initrd_file $boot_param acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp vga=normal |
|---|
| 211 | TEXT HELP |
|---|
| 212 | acpi=off irqpoll noapic noapm nodma nomce nolapic |
|---|
| 213 | nosmp vga=normal |
|---|
| 214 | ENDTEXT |
|---|
| 215 | |
|---|
| 216 | label local |
|---|
| 217 | # MENU DEFAULT |
|---|
| 218 | # MENU HIDE |
|---|
| 219 | MENU LABEL Local operating system in harddrive (if available) |
|---|
| 220 | # MENU PASSWD |
|---|
| 221 | # 2 method to boot local device: |
|---|
| 222 | # (1) For localboot 0, it is decided by boot order in BIOS, so uncomment the follow 1 line if you want this method: |
|---|
| 223 | # localboot 0 |
|---|
| 224 | |
|---|
| 225 | # (2) For chain.c32, you can assign the boot device. |
|---|
| 226 | # Ref: extlinux.doc from syslinux |
|---|
| 227 | # Syntax: APPEND [hd|fd]<number> [<partition>] |
|---|
| 228 | # [<partition>] is optional. |
|---|
| 229 | # Ex: |
|---|
| 230 | # Second partition (2) on the first hard disk (hd0); |
|---|
| 231 | # Linux would *typically* call this /dev/hda2 or /dev/sda2, then it's "APPEND hd0 2" |
|---|
| 232 | # |
|---|
| 233 | kernel chain.c32 |
|---|
| 234 | append hd0 |
|---|
| 235 | TEXT HELP |
|---|
| 236 | Boot local OS from first hard disk if it's available |
|---|
| 237 | ENDTEXT |
|---|
| 238 | |
|---|
| 239 | BOOT_MENU_END |
|---|
| 240 | |
|---|
| 241 | if [ -e "$tmp_sys_files_path/$memtest_filename" ]; then |
|---|
| 242 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 243 | # Note! *.bin is specially purpose for syslinux, |
|---|
| 244 | # Do NOT use memtest.bin, use memtest instead of memtest.bin |
|---|
| 245 | label memtest |
|---|
| 246 | # MENU DEFAULT |
|---|
| 247 | # MENU HIDE |
|---|
| 248 | MENU LABEL Memory test using Memtest86+ |
|---|
| 249 | # MENU PASSWD |
|---|
| 250 | kernel $sys_files_dir/$memtest_filename |
|---|
| 251 | TEXT HELP |
|---|
| 252 | Run memory test using Memtest86+ |
|---|
| 253 | ENDTEXT |
|---|
| 254 | |
|---|
| 255 | BOOT_MENU_END |
|---|
| 256 | fi |
|---|
| 257 | |
|---|
| 258 | # The following depends on the image exists or not |
|---|
| 259 | if [ -e "$tmp_sys_files_path/freedos.img" ]; then |
|---|
| 260 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 261 | label FreeDOS |
|---|
| 262 | # MENU DEFAULT |
|---|
| 263 | # MENU HIDE |
|---|
| 264 | MENU LABEL FreeDOS |
|---|
| 265 | # MENU PASSWD |
|---|
| 266 | kernel memdisk |
|---|
| 267 | append initrd=$sys_files_dir/freedos.img |
|---|
| 268 | TEXT HELP |
|---|
| 269 | Run FreeDOS |
|---|
| 270 | ENDTEXT |
|---|
| 271 | |
|---|
| 272 | BOOT_MENU_END |
|---|
| 273 | fi |
|---|
| 274 | if [ -e "$tmp_sys_files_path/eb.zli" ]; then |
|---|
| 275 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 276 | label etherboot |
|---|
| 277 | # MENU DEFAULT |
|---|
| 278 | # MENU HIDE |
|---|
| 279 | MENU LABEL Network boot via etherboot |
|---|
| 280 | # MENU PASSWD |
|---|
| 281 | kernel $sys_files_dir/eb.zli |
|---|
| 282 | TEXT HELP |
|---|
| 283 | Run Etherbot to enable network (PXE) boot |
|---|
| 284 | ENDTEXT |
|---|
| 285 | |
|---|
| 286 | BOOT_MENU_END |
|---|
| 287 | fi |
|---|
| 288 | } |
|---|
| 289 | # |
|---|
| 290 | gen_config_grub(){ |
|---|
| 291 | local grub_conf=$1 |
|---|
| 292 | local bg_img output_file |
|---|
| 293 | [ -z "$grub_conf" ] && grub_conf=menu.lst |
|---|
| 294 | bg_img="$(basename $ocs_logo_img_grub)" |
|---|
| 295 | output_file="$output_dir/$grub_conf" |
|---|
| 296 | # the timeout is in unit 1/10 sec, convert to sec for grub |
|---|
| 297 | timeout_sec="$(echo "scale=0; $timeout /10" | bc -l)" |
|---|
| 298 | echo "Adding grub menus for $output_title..." |
|---|
| 299 | cat <<-BOOT_MENU_END > $output_file |
|---|
| 300 | default 0 |
|---|
| 301 | timeout $timeout_sec |
|---|
| 302 | color cyan/blue white/blue |
|---|
| 303 | splashimage=/boot/grub/$bg_img |
|---|
| 304 | # since no network setting in the squashfs image, therefore if ip=frommedia, the network is disabled. |
|---|
| 305 | |
|---|
| 306 | title $output_title (Default settings$vga_800_600_prompt) |
|---|
| 307 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 308 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=$vga_mode |
|---|
| 309 | initrd /boot/$initrd_file |
|---|
| 310 | |
|---|
| 311 | BOOT_MENU_END |
|---|
| 312 | if [ "$show_vga_mode" = "2" ]; then |
|---|
| 313 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 314 | title $output_title (Default settings, VGA 640x480) |
|---|
| 315 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 316 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=$vga_mode |
|---|
| 317 | initrd /boot/$initrd_file |
|---|
| 318 | |
|---|
| 319 | BOOT_MENU_END |
|---|
| 320 | fi |
|---|
| 321 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 322 | title $output_title (to RAM, boot media can be removed later) |
|---|
| 323 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 324 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=$vga_mode toram |
|---|
| 325 | initrd /boot/$initrd_file |
|---|
| 326 | |
|---|
| 327 | BOOT_MENU_END |
|---|
| 328 | |
|---|
| 329 | if [ -n "$lang_locale" ]; then |
|---|
| 330 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 331 | title $output_title ($lang_locale, default settings$vga_800_600_prompt) |
|---|
| 332 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 333 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=$vga_mode locale=$lang_locale |
|---|
| 334 | initrd /boot/$initrd_file |
|---|
| 335 | |
|---|
| 336 | BOOT_MENU_END |
|---|
| 337 | if [ "$show_vga_mode" = "2" ]; then |
|---|
| 338 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 339 | title $output_title ($lang_locale, default settings, VGA 640x480) |
|---|
| 340 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 341 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=785 locale=$lang_locale |
|---|
| 342 | initrd /boot/$initrd_file |
|---|
| 343 | |
|---|
| 344 | BOOT_MENU_END |
|---|
| 345 | fi |
|---|
| 346 | |
|---|
| 347 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 348 | title $output_title ($lang_locale. To RAM. Boot media can be removed later) |
|---|
| 349 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 350 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=$vga_mode locale=$lang_locale toram |
|---|
| 351 | initrd /boot/$initrd_file |
|---|
| 352 | |
|---|
| 353 | BOOT_MENU_END |
|---|
| 354 | fi |
|---|
| 355 | |
|---|
| 356 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 357 | title $output_title Safe graphic settings (vga=normal) |
|---|
| 358 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 359 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param vga=normal |
|---|
| 360 | initrd /boot/$initrd_file |
|---|
| 361 | |
|---|
| 362 | title $output_title (Failsafe mode) |
|---|
| 363 | root ($op_hd_dev_grub,$op_part_no_grub) |
|---|
| 364 | kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp vga=normal |
|---|
| 365 | initrd /boot/$initrd_file |
|---|
| 366 | |
|---|
| 367 | BOOT_MENU_END |
|---|
| 368 | |
|---|
| 369 | if [ -e "$tmp_sys_files_path/$memtest_filename" ]; then |
|---|
| 370 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 371 | # Note! *.bin is specially purpose for syslinux, |
|---|
| 372 | # Do NOT use memtest.bin, use memtest instead of memtest.bin |
|---|
| 373 | title memtest |
|---|
| 374 | kernel $sys_files_dir/$memtest_filename |
|---|
| 375 | |
|---|
| 376 | BOOT_MENU_END |
|---|
| 377 | fi |
|---|
| 378 | |
|---|
| 379 | # The following depends on the image exists or not |
|---|
| 380 | |
|---|
| 381 | if [ -e "$tmp_sys_files_path/freedos.img" ]; then |
|---|
| 382 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 383 | title FreeDOS |
|---|
| 384 | kernel memdisk |
|---|
| 385 | initrd $sys_files_dir/freedos.img |
|---|
| 386 | |
|---|
| 387 | BOOT_MENU_END |
|---|
| 388 | fi |
|---|
| 389 | if [ -e "$tmp_sys_files_path/eb.zli" ]; then |
|---|
| 390 | cat <<-BOOT_MENU_END >> $output_file |
|---|
| 391 | title etherboot |
|---|
| 392 | kernel $sys_files_dir/eb.zli |
|---|
| 393 | BOOT_MENU_END |
|---|
| 394 | fi |
|---|
| 395 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
|---|
| 396 | echo "$msg_modify_grub_config_if_necessary:" |
|---|
| 397 | echo "$msg_delimiter_star_line" |
|---|
| 398 | echo "root ($op_hd_dev_grub,$op_part_no_grub)" |
|---|
| 399 | echo "kernel /boot/$kernel_file root=$output_dev_grub ro $boot_param" |
|---|
| 400 | echo "$msg_delimiter_star_line" |
|---|
| 401 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
|---|
| 402 | } |
|---|
| 403 | # |
|---|
| 404 | # Default settings |
|---|
| 405 | show_vga_mode="2" |
|---|
| 406 | # Parse command-line options |
|---|
| 407 | while [ $# -gt 0 ]; do |
|---|
| 408 | case "$1" in |
|---|
| 409 | -l|--language) |
|---|
| 410 | shift |
|---|
| 411 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 412 | # skip the -xx option, in case |
|---|
| 413 | specified_lang="$1" |
|---|
| 414 | shift |
|---|
| 415 | fi |
|---|
| 416 | [ -z "$specified_lang" ] && USAGE && exit 1 |
|---|
| 417 | ;; |
|---|
| 418 | -b|--bg-mode) |
|---|
| 419 | shift |
|---|
| 420 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 421 | # skip the -xx option, in case |
|---|
| 422 | bg_mode="$1" |
|---|
| 423 | shift |
|---|
| 424 | fi |
|---|
| 425 | [ -z "$bg_mode" ] && USAGE && exit 1 |
|---|
| 426 | ;; |
|---|
| 427 | -f|--framebuffer-mode) |
|---|
| 428 | shift |
|---|
| 429 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 430 | # skip the -xx option, in case |
|---|
| 431 | vga_mode="$1" |
|---|
| 432 | shift |
|---|
| 433 | fi |
|---|
| 434 | [ -z "$vga_mode" ] && USAGE && exit 1 |
|---|
| 435 | ;; |
|---|
| 436 | -t|--timeout) |
|---|
| 437 | shift |
|---|
| 438 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 439 | # skip the -xx option, in case |
|---|
| 440 | timeout="$1" |
|---|
| 441 | shift |
|---|
| 442 | fi |
|---|
| 443 | [ -z "$timeout" ] && USAGE && exit 1 |
|---|
| 444 | ;; |
|---|
| 445 | -g1|grub-hd-dev) |
|---|
| 446 | shift |
|---|
| 447 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 448 | # skip the -xx option, in case |
|---|
| 449 | op_hd_dev_grub="$1" |
|---|
| 450 | shift |
|---|
| 451 | fi |
|---|
| 452 | [ -z "$op_hd_dev_grub" ] && USAGE && exit 1 |
|---|
| 453 | ;; |
|---|
| 454 | -g2|grub-part-no) |
|---|
| 455 | shift |
|---|
| 456 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 457 | # skip the -xx option, in case |
|---|
| 458 | op_part_no_grub="$1" |
|---|
| 459 | shift |
|---|
| 460 | fi |
|---|
| 461 | [ -z "$op_part_no_grub" ] && USAGE && exit 1 |
|---|
| 462 | ;; |
|---|
| 463 | -g3|OS-root-dev) |
|---|
| 464 | shift |
|---|
| 465 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 466 | # skip the -xx option, in case |
|---|
| 467 | output_dev_grub="$1" |
|---|
| 468 | shift |
|---|
| 469 | fi |
|---|
| 470 | [ -z "$output_dev_grub" ] && USAGE && exit 1 |
|---|
| 471 | ;; |
|---|
| 472 | -k|--kernel-file) |
|---|
| 473 | shift |
|---|
| 474 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 475 | # skip the -xx option, in case |
|---|
| 476 | kernel_file="$1" |
|---|
| 477 | shift |
|---|
| 478 | fi |
|---|
| 479 | [ -z "$kernel_file" ] && USAGE && exit 1 |
|---|
| 480 | ;; |
|---|
| 481 | -i|--initrd-file) |
|---|
| 482 | shift |
|---|
| 483 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 484 | # skip the -xx option, in case |
|---|
| 485 | initrd_file="$1" |
|---|
| 486 | shift |
|---|
| 487 | fi |
|---|
| 488 | [ -z "$initrd_file" ] && USAGE && exit 1 |
|---|
| 489 | ;; |
|---|
| 490 | -n|--version-no) |
|---|
| 491 | shift |
|---|
| 492 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 493 | # skip the -xx option, in case |
|---|
| 494 | version_no="$1" |
|---|
| 495 | shift |
|---|
| 496 | fi |
|---|
| 497 | [ -z "$version_no" ] && USAGE && exit 1 |
|---|
| 498 | ;; |
|---|
| 499 | -p|--boot-param) |
|---|
| 500 | shift |
|---|
| 501 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 502 | # skip the -xx option, in case |
|---|
| 503 | boot_param="$1" |
|---|
| 504 | shift |
|---|
| 505 | fi |
|---|
| 506 | [ -z "$boot_param" ] && USAGE && exit 1 |
|---|
| 507 | ;; |
|---|
| 508 | -e|--title) |
|---|
| 509 | shift |
|---|
| 510 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 511 | # skip the -xx option, in case |
|---|
| 512 | output_title="$1" |
|---|
| 513 | shift |
|---|
| 514 | fi |
|---|
| 515 | [ -z "$output_title" ] && USAGE && exit 1 |
|---|
| 516 | ;; |
|---|
| 517 | -m|--bgimg) |
|---|
| 518 | shift |
|---|
| 519 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 520 | # skip the -xx option, in case |
|---|
| 521 | bgimg_file="$1" |
|---|
| 522 | shift |
|---|
| 523 | fi |
|---|
| 524 | [ -z "$bgimg_file" ] && USAGE && exit 1 |
|---|
| 525 | ;; |
|---|
| 526 | -s|--show-only-one-vga) |
|---|
| 527 | shift |
|---|
| 528 | show_vga_mode="1" |
|---|
| 529 | ;; |
|---|
| 530 | -z|--add-lang-menu) |
|---|
| 531 | shift |
|---|
| 532 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
|---|
| 533 | # skip the -xx option, in case |
|---|
| 534 | lang_locale="$1" |
|---|
| 535 | shift |
|---|
| 536 | fi |
|---|
| 537 | [ -z "$lang_locale" ] && USAGE && exit 1 |
|---|
| 538 | ;; |
|---|
| 539 | -*) echo "${0}: ${1}: invalid option" >&2 |
|---|
| 540 | USAGE >& 2 |
|---|
| 541 | exit 2 ;; |
|---|
| 542 | *) break ;; |
|---|
| 543 | esac |
|---|
| 544 | done |
|---|
| 545 | |
|---|
| 546 | output_format="$1" |
|---|
| 547 | output_dir="$2" |
|---|
| 548 | [ -z "$output_format" ] && USAGE && exit 1 |
|---|
| 549 | [ -z "$output_dir" ] && USAGE && exit 1 |
|---|
| 550 | [ -z "$vga_mode" ] && vga_mode=$VGA_MODE_DEF |
|---|
| 551 | [ -z "$timeout" ] && timeout=$TIMEOUT_DEF |
|---|
| 552 | [ -z "$kernel_file" ] && kernel_file="$KERNEL_FILE_DEFAULT" |
|---|
| 553 | [ -z "$initrd_file" ] && initrd_file="$INITRD_FILE_DEFAULT" |
|---|
| 554 | [ -z "$boot_param" ] && boot_param="$BOOT_PARAM_DEFAULT" |
|---|
| 555 | [ -z "$op_hd_dev_grub" ] && op_hd_dev_grub="$OP_HD_DEV_GRUB_DEF" |
|---|
| 556 | [ -z "$op_part_no_grub" ] && op_part_no_grub="$OP_PART_NO_GRUB_DEF" |
|---|
| 557 | [ -z "$output_dev_grub" ] && output_dev_grub="$OUTPUT_DEV_GRUB_DEF" |
|---|
| 558 | [ -z "$output_title" ] && output_title="$OUTPUT_TITLE_DEF" |
|---|
| 559 | [ -z "$bgimg_file" ] && bgimg_file="$BGIMG_FILE_DEF" |
|---|
| 560 | # |
|---|
| 561 | if [ -n "$(echo $output_title | grep -i clonezilla)" ]; then |
|---|
| 562 | boot_menu_txt_say_pkg="Clonezilla, the OpenSource Clone System." |
|---|
| 563 | boot_menu_txt_say_org="NCHC Free Software Labs, Taiwan." |
|---|
| 564 | project_url="clonezilla.sourceforge.net, clonezilla.nchc.org.tw" |
|---|
| 565 | boot_menu_pkg_ver_cpright="* Clonezilla live version: $version_no. (C) 2003-2008, NCHC, Taiwan" |
|---|
| 566 | boot_menu_pkg_disclaimer="* Disclaimer: Clonezilla comes with ABSOLUTE NO WARRANTY" |
|---|
| 567 | elif [ -n "$(echo $output_title | grep -i drbl)" ]; then |
|---|
| 568 | boot_menu_txt_say_pkg="DRBL (Diskless Remote Boot in Linux)." |
|---|
| 569 | boot_menu_txt_say_org="NCHC Free Software Labs, Taiwan." |
|---|
| 570 | project_url="drbl.sourceforge.net, drbl.nchc.org.tw" |
|---|
| 571 | boot_menu_pkg_ver_cpright="* DRBL live version: $version_no. (C) 2003-2008, NCHC, Taiwan" |
|---|
| 572 | boot_menu_pkg_disclaimer="* Disclaimer: DRBL comes with ABSOLUTE NO WARRANTY" |
|---|
| 573 | elif [ -n "$(echo $output_title | grep -i gparted)" ]; then |
|---|
| 574 | boot_menu_txt_say_pkg="GParted." |
|---|
| 575 | boot_menu_txt_say_org="Gnome Partition Editor." |
|---|
| 576 | project_url="http://gparted.sourceforge.net" |
|---|
| 577 | boot_menu_pkg_ver_cpright="* GParted live version: $version_no. Live version maintainer: $GPARTED_LIVE_MAINTAINER" |
|---|
| 578 | boot_menu_pkg_disclaimer="* Disclaimer: GParted live comes with ABSOLUTE NO WARRANTY" |
|---|
| 579 | elif [ -n "$(echo $output_title | grep -i LiveKoha)" ]; then |
|---|
| 580 | boot_menu_txt_say_pkg="LiveKoha" |
|---|
| 581 | boot_menu_txt_say_org="NCHC Free Software Labs, Taiwan." |
|---|
| 582 | project_url="koha.nchc.org.tw" |
|---|
| 583 | boot_menu_pkg_ver_cpright="* LiveKoha version: 3.0.0-beta. Live version maintainer: Thomas Tsai" |
|---|
| 584 | else |
|---|
| 585 | project_url="Welcome!" |
|---|
| 586 | fi |
|---|
| 587 | # |
|---|
| 588 | # Now we put other boot image files, like etherboot, fdos and memtest in the same dir with kernel and initrd. Therefore using $sys_files_dir (Ex: /casper, /live). This is used for the config file of boot manager (grub, syslinux). |
|---|
| 589 | sys_files_dir="$(dirname $kernel_file)" |
|---|
| 590 | # This is the absolute path for the output dir. |
|---|
| 591 | tmp_sys_files_path="$(dirname $output_dir)/$sys_files_dir" |
|---|
| 592 | ask_and_load_lang_set $specified_lang |
|---|
| 593 | |
|---|
| 594 | # |
|---|
| 595 | case "$bg_mode" in |
|---|
| 596 | txt|TXT|text|TEXT) |
|---|
| 597 | MENUC32="menu.c32" |
|---|
| 598 | mask="#" |
|---|
| 599 | ;; |
|---|
| 600 | *) |
|---|
| 601 | MENUC32="vesamenu.c32" ;; |
|---|
| 602 | esac |
|---|
| 603 | |
|---|
| 604 | # get memtest filename |
|---|
| 605 | # We no longer to use memtest_filename="$(basename $memtest86_file)", since if the filename is too long, if it's FAT (like in USB flash drive), it will go wrong. |
|---|
| 606 | # We use memtest to overwrite the one comes from Debian live |
|---|
| 607 | memtest_filename="memtest" |
|---|
| 608 | |
|---|
| 609 | # |
|---|
| 610 | case "$show_vga_mode" in |
|---|
| 611 | 1) vga_800_600_prompt="" ;; |
|---|
| 612 | *) vga_800_600_prompt=", VGA 800x600" ;; |
|---|
| 613 | esac |
|---|
| 614 | # |
|---|
| 615 | case "$output_format" in |
|---|
| 616 | isolinux|ISOLINUX) |
|---|
| 617 | gen_config_syslinux isolinux ;; |
|---|
| 618 | syslinux|SYSLINUX) |
|---|
| 619 | gen_config_syslinux syslinux ;; |
|---|
| 620 | grub|GRUB) |
|---|
| 621 | gen_config_grub menu.lst ;; |
|---|
| 622 | esac |
|---|