tldr: Here do this!
#!/bin/bash # This script is TheFunk's kinda shitty disk/OS detector. # In the years to come this is definitely going to be rewritten in # something more convenient. # Also TheFunk didn't write any pretty GUI that might be related to this. TheFunk is terrible with visuals. <img src='http://www.binrev.com/forums/public/style_emoticons/<#EMO_DIR#>/;).gif' class='bbc_emoticon' alt=';)' /> # First we use parted/egrep to find available disks, their location in /dev, and their sizes. # Then sed does a little corrective formatting and we save everything to a text file. clear echo "In a moment you'll see a list of available drives, and information about them." sleep 3 parted -l | egrep '/dev/(s|h)d[a-z]' | sed 's/://' > thesemahdisks # Next we pause before examining the disks. This can be removed # and done automatically, but I figured it would be good for stopping # the script. Also I'm lazy, what else is new? clear echo "It would appear as if you have `cat thesemahdisks | wc -l` disks installed in, or otherwise plugged into this system." echo "" echo "Now we'll examine those disks. Please press Enter." read hold clear disknumber=1 totesdisks=`cat thesemahdisks | wc -l` looper=true # Here's where things get weird. Bash used to hate incrementing numbers. # This was giving all sorts of weird output earlier. It appears to be # working sorta correctly now though. After some hair pulling... while [ $looper ] do if [ "$disknumber" -le "$totesdisks" ]; then examinee=`sed -n "$disknumber p" thesemahdisks | cut -d' ' -f2` # echo parted $examinee print *This line can be removed.* echo "" totesparts=`parted $examinee print | cut -c 2 | sed 's/[A-Za-z]*//g' | sed '/^$/d' | wc -l` echo "Disk number " $disknumber " has " $totesparts " partitions." echo "" mkdir -p /mnt/temp currentpart=1 newlooper=true while [ $newlooper ] do if [ "$currentpart" -le "$totesparts" ]; then mount $examinee$currentpart /mnt/temp if [ -f /mnt/temp/bootmgr ]; then echo "OS for partition " $examinee$currentpart " is Windows Vista or 7." elif [ -f /mnt/temp/ntldr ]; then echo "OS for partition " $examinee$currentpart " is Windows XP or older." # Kinda borrowed this. # Thanks Internet. elif [ -f /mnt/temp/etc/debian_version ]; then echo "OS for partition " $examinee$currentpart " is Debian Linux." elif [ -f /mnt/temp/etc/redhat-release ]; then echo "OS for partition " $examinee$currentpart "is RedHat Linux." elif [ -f /mnt/temp/etc/SuSE-release ]; then echo "OS for partition " $examinee$currentpart " is OpenSuSE Linux." # /end partly borrowed code elif [ -f /mnt/temp/etc/lsb-release ]; then echo "Ignore the next line if it's a repeat." echo "OS for partition " $examinee$currentpart "is " `cat lsb-release | cut -d"=" -f2 | sed -n "1 p"` else echo "Could not find OS information for partition " $examinee$currentpart echo "Moving to next partition." sleep 2 fi umount /mnt/temp 2> errorlog ((currentpart++)) else echo "" echo "We're either all done, or there are no partitions here brah." echo "" sleep 2 break fi newlooper=false done ((disknumber++)) else echo "We're all done mayne." sleep 2 break fi looper=false done echo "" echo "We're done here." echo "Press Enter to end the program" read hold clear echo "Quitting in...3 seconds" sleep 1 clear echo "Quitting in...2 seconds" sleep 1 clear echo "Quitting in...1 second" sleep 1 exit 0