home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / os-probes / mounted / 20microsoft < prev    next >
Encoding:
Text File  |  2006-08-21  |  1.8 KB  |  62 lines

  1. #!/bin/sh
  2. # Detects all Microsoft OSes on a collection of partitions.
  3.  
  4. . /usr/share/os-prober/common.sh
  5.  
  6. partition=$1
  7. mpoint=$2
  8. type=$3
  9.  
  10. # Weed out stuff that doesn't apply to us
  11. case "$type" in
  12.   ntfs) debug "$1 is a NTFS partition" ;;
  13.   vfat) debug "$1 is a FAT32 partition" ;;
  14.   msdos) debug "$1 is a FAT16 partition" ;;
  15.   *) debug "$1 is not a MS partition: exiting"; exit 1 ;;
  16. esac
  17.  
  18. # Vista/Longhorn
  19. if [ -e "$2/bootmgr" ] && [ -e "$2/Boot/BCD" ]; then
  20.   long="Windows Vista/Longhorn (loader)"
  21.   short=Windows
  22. # 2000/XP/NT4.0
  23. elif [ -e "$2/ntldr" ] && [ -e "$2/NTDETECT.COM" ]; then
  24.   long="Windows NT/2000/XP"
  25.   short=Windows
  26.   if [ -e "$2/boot.ini" ]; then
  27.     multicount="$(grep -e "^multi" $2/boot.ini | wc -l)"
  28.     scsicount="$(grep -e "^scsi" $2/boot.ini | wc -l)"
  29.     msoscount="$(expr ${multicount} + ${scsicount})"
  30.     if [ $msoscount -eq 1 ]; then
  31.       # We need to remove a Carriage Return at the end of the line...
  32.       defaultmspart="$(grep -e "^default=" $2/boot.ini | cut -d '=' -f2 | tr -d '\r')"
  33.       # Escape any backslashes in defaultmspart
  34.       grepexp="^$(echo $defaultmspart | sed -e 's/\\/\\\\/')="
  35.       # Colons not allowed; replace by spaces
  36.       # Accented characters (non UTF-8) cause debconf to hang, so we fall back
  37.       # to the default if the name contains any weird characters.
  38.       long="$(grep -e "$grepexp" $2/boot.ini | cut -d '"' -f2 | \
  39.             tr ':' ' ' | grep -v '[^a-zA-Z0-9 &()/_-]')"
  40.       if [ -z "$long" ]; then
  41.         long="Windows NT/2000/XP"
  42.       fi
  43.     else
  44.       long="Windows NT/2000/XP (loader)"
  45.     fi
  46.   fi
  47. # MS-DOS
  48. elif [ -d "$2/dos" ]; then
  49.   long="MS-DOS 5.x/6.x/Win3.1"
  50.   short=MS-DOS
  51. # 95/98/Me
  52. elif [ -e "$2/windows/win.com" ]; then
  53.   long="Windows 95/98/Me"
  54.   short=Windows9xMe
  55. else
  56.   exit 1
  57. fi
  58.  
  59. label=$(count_next_label $short)
  60. result "${partition}:${long}:${label}:chain"
  61. exit 0
  62.