NetRestore – Specifying Packages to install using PHP Services

by on September 15, 2007 » Add the first comment.

NetRestore PHP Services helps automate machine deployments by automating several tasks such as machine naming, network configuration and specifying which image is used for groups of machines and several other preferences. It can also be customized to add funtionality for tasks that are not already built in. This post will explain how to specify which packages to install as a post-action script.
In order to do this, we need to create a machine specific attribute, create a folder for our packages on the share point our images are stored on and modify the install-pkgs.sh that is included with NetRestore.

Machine Specific Attribute

In your NetRestore PHP Services website, click on Database Administration > Create Machine Specific Attributes. From the Data Type menu, select Text (512 characters max) and in the Field Name type packages. Click the Create Field button.

Store Packages Somewhere

I created a Packages directory on my Images sharepoint. You could probably also use your NetBootSPn sharepoint, you will just need to specify the different path in the next step. Make sure your “Imaging” user (the user you created to grab the image from your images share) has read access.

Modify install-pkgs.sh

In any recent NetRestore folder, you will find install-pkgs.sh in the Resources > Example Scripts > post-actions folder. This file is configured to look at a machine_specific_data.csv file. Instead of going through line by line on what needs to be changed, I will just post my install-pkgs.sh contents below. You may need to modify the pkgdir property to reflect the location of your packages. You can also download the script from here.

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
 
############################ install-pkgs.sh #########################
# Mike Bombich | mike@bombich.com
# Copyright 2004 Mike Bombich
# This is a lab machine post-installation customization script for
# use with NetRestore: http://www.bombich.com/software/netrestore.html
#
# Modified by Patrick Gallagher | http://macadmincorner.com
# For use with NetRestore PHP Services
# Customizations needed to PHP Services before implementing
######################################################################
 
### Description ###
#
## This script installs packages indicated in the packages field of your PHP Services website
 
 
### Properties ###
paDir=`dirname "$0"`
myRecord=/tmp/myRecord
hwAddress=`ifconfig en0 | awk '/ether/ { gsub(":", ""); print $2 }'`
 
# pkgDir is the parent directory containing all of your packages
# Its a good idea to keep this on the same sharepoint as your disk images
# The example below indicates the path of a mounted AFP sharepoint
pkgdir="/Volumes/Images/Packages/"
 
# Retrieve the space-delimited list of packages from the machine's entry
# in the PHP site
pkgs=`defaults read $myRecord packages`
 
 
### Script action ###
for pkg in $pkgs
do
installer -pkg "$pkgdir"/"$pkg" -target "$1"
done

Store this script in your NetBootSPx/Resources/post-install folder. Or if you want it to only apply to a certain NetBoot image (.nbi), put it in the appropriate NetInstall-Restore.dmg/Applications/Utilities/Resources folder. Make sure the script is executable and readable by everyone.

Specify Packages to be installed

From your PHP Services website, go to Data Management > Machine Specific Information and select a machine group from the pull down menu. Then in your newly created packages field, enter the packages you want those machines to install. They need to be entered as space delimited and without spaces in the package names. The file name extension (.pkg) needs to be included as well.

Note: If you add more machines to a particular group, you will need to apply these settings again because the Machine Specific Settings (and NetRestore Preferences for that matter) are stored in each machines record, not the group even through you are applying the settings to the group. There is a message regarding this at the bottom of those pages.


Test Test Test
NetBoot one of the Macs that was included in that group and verify the install-pkgs.sh script is run. If you want to monitor the progress, open a Terminal window from the Tools menu and type:

tail -f /var/log/netrestore.log

Find more like this: Automation, Imaging, Mac, Software Packaging , , , , ,


Leave a Reply

Your email address will not be published. Required fields are marked *