#!/bin/bash
#Clear ZISD
zisedit -c
#Detect type of drive and set HDD variable
HDD=`img p | grep -E ^1 | awk '{print $2}'`
#Delete all partitions and create temp
img pdall
img pc1 fat16 10
if echo $HDD | grep hda ; then
sleep 40
fi
if echo $HDD | grep hda ; then
echo w> /tmp/test
fdisk /dev/hda < /tmp/test
fi
mkfs.msdos $HDD
#Restore sysprep.inf template
img rp $PROXYADDR //$PROXYADDR/vol1/images/sysprep_template.zmg
mount $HDD /mnt/harddisk
#Search sysprep for MYNAME and replace with Service Tag
sed -i s/MYNAME/$(zhw -serial)/g /mnt/harddisk/sysprep/sysprep.inf
umount /mnt/harddisk
#Create image of sysprep changes in local temp location
img ml /tmp/$(zhw -serial).zmg
#Restore base image, Enable DMA if IDE hard drive
if echo $HDD | grep hda ; then hdparm -d1 /dev/hda ; fi
img rp $PROXYADDR //$PROXYADDR/vol1/images/basexp.zmg
#Non-destructively restore sysprep.inf over one in base image
img rl /tmp/$(zhw -serial).zmg a1:p1
#Restore drivers for specific model computer
hwinfo --bios > /tmp/hwinfo.bios
if cat /tmp/hwinfo.bios | grep -i "Optiplex GX620" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/gx620driver.zmg
elif cat /tmp/hwinfo.bios | grep -i "Optiplex 745" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/745driver.zmg
elif cat /tmp/hwinfo.bios | grep -i "OptiPlex GX270" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/gx270driver.zmg
elif cat /tmp/hwinfo.bios | grep -i "Latitude D620" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/d620driver.zmg
elif cat /tmp/hwinfo.bios | grep -i "Latitude D610" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/d610driver.zmg
elif cat /tmp/hwinfo.bios | grep -i "Latitude D600" ; then
img rp $PROXYADDR //$PROXYADDR/vol1/images/addon/d600driver.zmg
fi
#Set computer name in ZISD as Service Tag
zisedit ComputerName=$(zhw -serial)