#! /bin/bash # # KURO-BOX boot selector (Type 2: no-console style) # (c) 2005-2008 Eiji Kawauchi # (2008-04-01) # default values timeout=3 bootdefault=1 #AVR=/dev/AVR00 menu2="NetBSD(HDD:wd0a)" loader2=/lib/modules/`/bin/uname -r`/kernel/nbloader_v3.o kernel2=/boot/netbsd.bin option2='cmdline="bootdev=wd0a"' menu3= loader3= kernel3= option3= menu4= loader4= kernel4= option4= menu5= loader5= kernel5= option5= menu6= loader6= kernel6= option6= menu7= loader7= kernel7= option7= menu8= loader8= kernel8= option8= menu9= loader9= kernel9= option9= # This may override above if [ -f /etc/default/kuro_boot.conf ]; then . /etc/default/kuro_boot.conf fi # if [ -f /etc/kuro_boot.conf ]; then . /etc/kuro_boot.conf fi # if [ -f /etc/kuro_boot.tmp ]; then . /etc/kuro_boot.tmp /bin/rm -f /etc/kuro_boot.tmp fi # functions init_avr() { if [ "$AVR"x = ""x ]; then if [ -c /dev/AVR00 ]; then /bin/echo /dev/AVR00 detected. AVR=/dev/AVR00 elif [ -c /dev/ttyS1 ]; then /bin/echo /dev/ttyS1 detected. AVR=/dev/ttyS1 else exit 0; fi fi # AVR Control /bin/stty -F $AVR cs8 parenb -parodd clocal 9600 /bin/echo -n 'AAAAFFFFJJJJ>>>>VVVV>>>>ZZZZVVVVKKKK' > $AVR /bin/echo -n '[[[[' > $AVR } boot_kernel() { if [ "$1"x = ""x ]; then #/bin/echo "Loader not specified." return 1; fi if [ ! -f $1 ]; then #/bin/echo "Loader does not exist." return 1; fi if [ "$2"x = ""x ]; then /bin/echo "Kernel not spicified." /boot/tools/kuro_morse F $AVR return 0; fi if [ ! -f $2 ]; then /bin/echo "Kernel does not exist." /boot/tools/kuro_morse F $AVR return 0; fi init_avr /bin/sync; /bin/sync; /bin/umount -a /bin/mount -n -o remount,ro / /sbin/insmod $1 kernel=$2 $3 # insmod failed /boot/tools/kuro_morse F $AVR return 0; } select_boot() { /bin/echo "************************************************" /bin/echo "Select the OS in $timeout secs: (default is $bootdefault)" /bin/echo "1: Linux" if [ "$menu2"x != ""x ]; then /bin/echo "2: $menu2" fi if [ "$menu3"x != ""x ]; then /bin/echo "3: $menu3" fi if [ "$menu4"x != ""x ]; then /bin/echo "4: $menu4" fi if [ "$menu5"x != ""x ]; then /bin/echo "5: $menu5" fi if [ "$menu6"x != ""x ]; then /bin/echo "6: $menu6" fi if [ "$menu7"x != ""x ]; then /bin/echo "7: $menu7" fi if [ "$menu8"x != ""x ]; then /bin/echo "8: $menu8" fi if [ "$menu9"x != ""x ]; then /bin/echo "9: $menu9" fi /bin/echo "" # Light "DISK FULL" LED (for indication) /bin/echo -n "WWWW" > $AVR # Input /boot/tools/kuro_swread $timeout $AVR select=$? # LED off /bin/echo -n "VVVV" > $AVR } if [ "$1"x = "start"x ]; then # AVR Control init_avr # Input select_boot if [ "$select"x = "0"x ]; then /bin/echo '** Default **' select=$bootdefault fi /bin/echo "** No.$select **" /bin/sleep 1 case $select in 1) /boot/tools/kuro_morse E $AVR ;; 2) /boot/tools/kuro_morse I $AVR boot_kernel "$loader2" "$kernel2" "$option2" if [ "$?" = "1" ]; then select=1 fi ;; 3) /boot/tools/kuro_morse S $AVR boot_kernel "$loader3" "$kernel3" "$option3" if [ "$?" = "1" ]; then select=1 fi ;; 4) /boot/tools/kuro_morse H $AVR boot_kernel "$loader4" "$kernel4" "$option4" if [ "$?" = "1" ]; then select=1 fi ;; 5) /boot/tools/kuro_morse 5 $AVR boot_kernel "$loader5" "$kernel5" "$option5" if [ "$?" = "1" ]; then select=1 fi ;; 6) /boot/tools/kuro_morse N $AVR boot_kernel "$loader6" "$kernel6" "$option6" if [ "$?" = "1" ]; then select=1 fi ;; 7) /boot/tools/kuro_morse D $AVR boot_kernel "$loader7" "$kernel7" "$option7" if [ "$?" = "1" ]; then select=1 fi ;; 8) /boot/tools/kuro_morse B $AVR boot_kernel "$loader8" "$kernel8" "$option8" if [ "$?" = "1" ]; then select=1 fi ;; 9) /boot/tools/kuro_morse 6 $AVR boot_kernel "$loader9" "$kernel9" "$option9" if [ "$?" = "1" ]; then select=1 fi ;; *) /boot/tools/kuro_morse E $AVR select=1 ;; esac if [ "$select" != "1" ]; then /bin/echo "Oops, Boot failed..." fi fi