diff options
Diffstat (limited to 'packages/altboot/files/set-bootdev')
-rwxr-xr-x | packages/altboot/files/set-bootdev | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/packages/altboot/files/set-bootdev b/packages/altboot/files/set-bootdev deleted file mode 100755 index 60d0283dc4..0000000000 --- a/packages/altboot/files/set-bootdev +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh - -VERSION="0.0.1" -ENABLE_DEBUG="yes" - -die() { - echo -e "ERROR: $1" - exit 1 -} - -. /etc/altboot.func || die "/etc/altboot.func is missing!" -test -d /sys/block || die "Sysfs problem? (/sys/block not found)" - -debug_echo() { - test "$ENABLE_DEBUG" = "yes" && echo -e "${C_YELLOW}DEBUG:${C_RESET}${C_WHITE} $1 ${C_RESET}" -} - -scan_devices() { - reset_pref "available_devices" - - cnt=1 - set_pref "available_devices" "$cnt" "Flash" ; let cnt=$cnt+1 - - for scsi_disk in `ls -1 /sys/block/ | grep ^sd` - do - scsi_disk_name="`echo "$scsi_disk" | awk '{printf("%s\n",toupper($0))}'`" - test -e /sys/block/$scsi_disk/device/vendor && HDD_VENDOR="`cat /sys/block/$scsi_disk/device/vendor | sed "s/\ $//"`" - test -z "$HDD_VENDOR" && HDD_VENDOR="Unknown Vendor" - - test -e /sys/block/$scsi_disk/device/model && HDD_MODEL="`cat /sys/block/$scsi_disk/device/model`" - test -z "$HDD_MODEL" && HDD_MODEL="Unknown Model" - - scsi_disk_partition_cnt="`ls -1 /sys/block/$scsi_disk | grep ^$scsi_disk | wc -l | tr -d " "`" - test "$scsi_disk_partition_cnt" -gt 1 && scsi_disk_partition_cnt="$scsi_disk_partition_cnt partitions" || scsi_disk_partition_cnt="$scsi_disk_partition_cnt partition" - - set_pref "available_devices" "$cnt" "$scsi_disk_name ( $HDD_VENDOR $HDD_MODEL with $scsi_disk_partition_cnt)" - set_pref "available_devices_short" "$cnt" "$scsi_disk" - set_pref "available_devices_type" "$cnt" "usb" - - let cnt=$cnt+1 - done - -} - -show_menu() { - echo -e "\nset-bootdev v$VERSION\n" - - echo -e "Please select the device you wish to boot from:\n" - - cnt2=0 ; let cnt=$cnt-1 - while test "$cnt" != "$cnt2" - do - let cnt2=$cnt2+1 - get_pref "available_devices" "$cnt2" dev - - echo -e "\t[$cnt2] - $dev" - done - - while test -z "$selected_dev" - do - echo -en "\nYour choice: " - read junk - get_pref "available_devices" "$junk" selected_dev - get_pref "available_devices_type" "$junk" part_mode - -# debug_echo "show_menu(): selected: [$selected_dev]" - done - - if ( echo "$selected_dev" | grep -q "^Flash" ) - then - boot_from flash - else - get_pref "available_devices_short" "$junk" selected_dev -# debug_echo "show_menu(): selected_devices_short: [$selected_dev]" - - partitions="`ls -1 /sys/block/$selected_dev|grep ^$selected_dev`" - test -z "$partitions" && die "No partitions found on /dev/$selected_dev!" - - - echo -e "\nPlease select a partition on $selected_dev to boot from:\n" - - cnt=1 - for partition in $partitions - do - # We assume that partitions with a "size" < 10 are extended partitions - # and should not be listed. TYPE=swap is blacklisted as well. - part_size="`cat /sys/block/$selected_dev/$partition/size`" - part_type="`blkid -s TYPE -o value /dev/$partition`" - - if test "$part_size" -gt 10 -a "$part_type" != "swap" - then - let part_size="($part_size/2)/1000" - echo -e "\t[$cnt] $partition (~ ${part_size}Mb, $part_type)" - set_pref "available_partitions" "$cnt" "$partition" - - let cnt=$cnt+1 - fi - done - - while test -z "$selected_partition" - do - echo -en "\nYour choice: " - read junk - get_pref "available_partitions" "$junk" selected_partition - done - - part_uuid="`blkid -c /dev/null -s UUID -o value /dev/$selected_partition`" - - boot_from "$part_mode" "$selected_partition" "$part_uuid" - fi -} - -boot_from() { - debug_echo "boot_from() [$*]" - - part_mode="$1" - part_name="$2" - part_uuid="$3" - - case "$part_mode" in - usb) umount /tmp/mnt.set-bootdev >/dev/null 2>&1 - rm -rf /tmp/mnt.set-bootdev ; mkdir -p /tmp/mnt.set-bootdev - - if ! ( mount -U "$part_uuid" /tmp/mnt.set-bootdev ) - then - echo "** Note: UUID mount for $part_name failed" - mount /dev/$part_name /tmp/mnt.set-bootdev && echo "** Note: Normal mount for $part_name successful" - fi - - if ! test -e /tmp/mnt.set-bootdev/sbin/init.sysvinit - then - copy_rootfs /tmp/mnt.set-bootdev/ - else - umount /tmp/mnt.set-bootdev - echo -e "\nSetting /dev/$part_name as boot-partition" - echo "$part_mode $part_name $part_uuid" > /etc/set-bootdev.conf - fi - ;; - flash) echo "Setting the onboard flash as boot-partition" - echo "$part_mode $part_name $part_uuid" > /etc/set-bootdev.conf - ;; - esac -} - -copy_rootfs() { - debug_echo "copy_rootfs() [$*]" -} - -scan_devices -show_menu |