In our Casper NetBoot, we launch Casper Imaging after auto-login for use with Pre-Stage and AutoRun (for conference room Macs that aren't encrypted). If a user needs to wipe an encrypted disk, they can cancel the login to Casper Imaging and run the following shell script by running an AppleScript launcher app that sits on the desktop.
It took a bit of trial and error, but the sleep commands eliminated any failures. We initially had issues due to the NetBoot not running completely in RAMDisk. Once we updated the rc.netboot file, this has been running flawlessly.
#!/bin/sh
macVolume=diskutil list | grep "Macintosh HD" | awk '{print $7}'
diskutil unmount force /dev/$macVolume
sleep 1
fdisk -i /dev/rdisk0
sleep 1
diskutil eraseDisk JHFS+ "Macintosh HD" GPT /dev/rdisk0
sleep 2
open -a Casper Imaging.app
*Edited post for clarity*
