Stop Typing in the Full Path during Imaging and Modifying Linux.2
Novell Cool Solutions: Tip
By Sibrand van Minnen
Reader Rating
from 8 ratings
|
Digg This -
Slashdot This
Posted: 20 Jul 2005 |
With Henny van de Ben I was inspired by the modifications from Jan Visser and Box Lawrence. We modified Linux.2 so that it gets a menu file from the TFTP dir on the ZENworks imaging server. The menufile is easy to modify -- it's plain text.
Example
Modification to Linux.2 /bin/prompt.s: #!/bin/ash . /bin/config.s manual mountFloppyifLS120 if [ $? != 0 ]; then echo "Failed to mount floppy drive. If there is a floppy in the drive, remove it before running img"; fi export MANUALREBOOT=YES export SHELLACTIVE=YES ## adition . /bin/getmenu.s ## end adition ash -rcfile /bin/bashrc
Addition to Linux2 - place this script in a file called getmenu.s #!/bin/bash tftp -c get $PROXYADDR:menu.txt /bin/menu chmod 777 /bin/menu menu
and make this script executable with chmod 777 getmenu.
Place the following text in the [zenserver]sys\tftp\menu.txt
#!/bin/bash
#
#
# Author:
# Sibrand van Minnen, Henny van der Ben , 2005
#
# Versie:
# 1.0 07 july 2005
#
# Function:
# Editable menu for PXE imaging without modifying Linux.2
# All the menu commands are in the standard kernel which
# comes with Zenworks.
###########################################################################
################################################ Variables
###################################### Path to images on Zen server
unc=data/img/test
###################################### TABLE: #I image-name
#
# Column 1: Table must begin with #I
# Column 2: Complete name from zmg file in image directory
#
######################################
#I xpsp2nl.zmg
#I sysprep.zmg
#I install.zmg
#I txtfiles.zmg
#I addinf.zmg
###################################### TABLE: #D driver-name
#
# Column 1: Table must begin with #D
# Column 2: Type must be without spaces
# Column 3: Number is itemnumber in menu
# Column 4: Complete name from zmg file in image directory
#
# Maximum 9 items
#
######################################
#D DC7100 1 dc7100.zmg
#D type2 2 driver2.zmg
#D type3 3 driver3.zmg
#D type4 4 driver4.zmg
#D type5 5 driver5.zmg
#D type1 6 drivers.zmg
#D type2 7 driver2.zmg
#D type3 8 driver3.zmg
#D type4 9 driver4.zmg
################################################ Functions
###################################### Clear screen
cls()
{
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
echo ""
done
}
###################################### Driver menu
drvmnu()
{
cls
echo "##########################"
echo "####### Driver menu ######"
echo "##########################"
echo ""
echo ""
########### Definition menu
grep "^\#D " $0|while read comment menuitem nummer naam
do echo " "[$nummer] $menuitem
done
echo " [0] Exit"
read drvimg
########### ZMG item restore
grep "^\#D " $0|while read comment menuitem nummer imagefile
do if test $drvimg -eq $nummer
then
zenimg
fi
done
if test $drvimg -ne 0
then
echo "reboot"
else
cls
echo "Thanx"
fi
}
###################################### 1e HDD active
acthdd()
{
hdparm -d1 /dev/hda1
}
###################################### Remove partitions
rempart()
{
img pd3
img pd2
img pd1
}
###################################### Remove C: partition
remc()
{
img pd1
}
###################################### Activate partitions
actpart()
{
img pa1
}
###################################### Restore images from TABEL image name
restpart()
{
grep "^\#I " $0|while read comment imagefile
do zenimg
done
}
###################################### Restore images
zenimg()
{
img rp $PROXYADDR //$PROXYADDR/$unc/$imagefile a1:p1
}
################################################ Begin program
###################################### Image menu
cls
echo "###################################################"
echo "####### Image menu #######"
echo "###################################################"
echo ""
echo ""
echo " [1] Restore Workstation"
echo " [2] Restore Workstation with custom C: partition"
echo " [3] Restore C: drive"
echo " [4] Create image"
echo " [0] Exit"
read image
case $image in
"1" )
###################################### 1e HDD active
acthdd
###################################### Remove partitions
rempart
###################################### Make 1e partitions 10Gb FAT32
img pc1 fat32 10240
###################################### Make 2e partition NTFS
img pc2 ntfs
###################################### Restore general images
restpart
###################################### Make 1e partition active
actpart
###################################### Restore driver image
drvmnu
;;
"2" )
cls
echo "Size C: partition:"
read part
###################################### 1e HDD active
acthdd
###################################### Remove partitions
rempart
###################################### Make 1e partitions 10Gb FAT32
img pc1 fat32 $part
###################################### Make 2e partition NTFS
img pc2 ntfs
###################################### Restore general images
restpart
###################################### Make 1e partition active
actpart
###################################### Restore driver image
drvmnu
;;
"3" )
echo "Restore C:"
###################################### 1e HDD active
acthdd
###################################### Remove partitions
remc
###################################### Make 1e partitions 10Gb FAT32
img pc1 fat32 10240
###################################### Make 2e partition NTFS
img pc2 ntfs
###################################### Restore general images
restpart
###################################### Make 1e partition active
actpart
###################################### Restore driver image
drvmnu
;;
"4" )
echo "Geef de naam voor de image, zonder zmg"
read naam
img mp $PROXYADDR //$PROXYADDR/$unc/$naam.zmg
;;
"0" )
;;
esac
exit 0
In the first 30 or so lines you can edit your image menus.
If you have any questions you may contact Sibrand at s.v.minnen@dehoogstraat.nl
Reader Comments
- This is the stuff I like!! Good work.
- If you are using the kernel 2.6.11 version from http://forge.novell.com/modules/xfmod/project/?zfdimgdrv You will need to modify the tftp command, as it does NOT work as described above. (It works with zen 6.5 and 6.5 sp1b). Use this command instead: tftp $PROXYADDR < /bin/getmenu2.s and create a getmenu2.s file that has the following commands: get menu.txt /bin/menu q -mhynek in Madison, WI
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com
