Polling for partition table script

jarednichols
Honored Contributor

Hi-

I recently posted that I needed to poll for partition table type on the list. I've written the basics of the script and figured someone else may need it. Here it is... copy, paste, modify... whatevs. Obviously, throw in your own comments into the code.

j

#!/bin/sh

PartitionType=diskutil list | grep 0:

case $PartitionType in
*Apple_partition_scheme)
echo "You have an Apple Partition Table" ## Add in whatever action you want like a "touch" command to place a dummy package
;;
*GUID_partition_scheme
)
echo "You have a GUID Partition Table" ## Add in whatever action you want like a "touch" command to place a dummy package
;;
esac

exit 0

---
Jared F. Nichols
Desktop Engineer, Infrastructure & Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

4 REPLIES 4

tlarkin
Honored Contributor

Jared,

I actually wrote a few interactive shell scripts for the IT department at my old job. We used Novell's Zen imaging and I used a script to run the commands from an interactive menu.

Here is an example of an OS X troubleshooting script I wrote a few years back that you could use as an example: I will bold it so enable HTML on your email.

#!/bin/bash

#This is a menu for basic diagnostics by Thomas Larkin

echo "Hello $USER, Welcome to the Tom's Diagnostic script!" echo "Today is ";date echo "Number of user logged in : " ; who | wc -l echo "Calendar" cal

selection= until [ "$selection" = "0" ]; do echo "" echo "Select an option please" echo "1 - Display all objects in /Volumes" echo "2 - Display total disk usage of /, this may take a while. You will be prompted for admin access" echo "3 - Display the disk usage of my Home Directory, this may take a while" echo "4 - Print the contents of /var/log/system.log" echo "5 - List all current users logged in this computer" echo "6 - Display my Network Settings and Information" echo "7 - Display my BASH command paths" echo "8 - Display all the current running processes" echo "9 - Display current resources being used" echo "10 - Display the print error log" echo "11 - Display the crash reporter log" echo "12 - Run Verify permissions on the boot volume" echo "13 - Run Repair Permissions on the boot volume" echo "14 - Run verify volume on the boot volume" echo "15 - list all information of boot volume" echo "0 - exit program" echo "" echo -n "Enter selection: " read selection echo "" case $selection in 1 ) /bin/ls -al /Volumes ;; 2 ) sudo /usr/bin/du -h -x / | sort ;; 3 ) /usr/bin/du -a -h -x /Users/$USER | sort ;; 4 ) /bin/cat /var/log/system.log ;; 5 ) /usr/bin/finger -h ;; 6 ) /sbin/ifconfig ;; 7 ) /bin/echo $PATH ;; 8 ) /bin/ps -A ;; 9 ) /usr/bin/top -s5 20 ;; 10 ) /bin/cat /var/log/cups/error_log ;; 11 ) /bin/cat /var/log/crashreporter.log ;; 12 ) /usr/sbin/diskutil verifyPermissions / ;; 13 ) /usr/sbin/diskutil repairPermissions / ;; 14 ) /usr/sbin/diskutil verifyVolume / ;; 15 ) /usr/sbin/diskutil list / ;; 0 ) exit ;; * ) echo "Please enter a valid option" esac done

So you could just edit the commands into a script of your own and run it and it can be interactive.



Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351
chown -R us /.base

jarednichols
Honored Contributor

We used Novell's Zen imaging
On Oct 19, 2009, at 2:08 PM, Thomas Larkin wrote:

::shudder::

nice script though :)
---
Jared F. Nichols
Desktop Engineer, Infrastructure & Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

tlarkin
Honored Contributor

It honestly wasn't bad, after we made my script run first automatically after a PXE boot you just hit a number and walked away from it.

tlarkin
Honored Contributor

I just copied and pasted that script from an old post of mine on a mac forum. It was written I think for 10.3 so you may have to alter it, let me know if you need any more help with it. I think that you could take my interactive script and modify it to do what you want to do.

Or, you could just do an expression to automate the whole thing if you are going to do a dummy package.

-Tom



Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351
chown -R us /.base