Part 2 – Tutorial of the basics of using InstaDMG with OSX Lion 10.7.
Please refer to Part 1 to get familiar with the basics of creating a simple ‘out of the box’ InstaDMG image of OSX 10.7.
Moving on from the initial image created with InstaDMG which will boot the Mac to a typical new vanilla installation, InstaDMGs real power is discovered in package and application installation and various scripts which can be bundled with the image, this tutorial extends from the base image to include a default user and also a small package which enables the image to boot up to bypass the default Apple Registration process so you are just booted straight to the login screen for the already created user.
This process requires a familiarity with basic Unix commands in OS X’s Terminal. Part 2 assumes you have the base OSX 10.7 image already in InstaDMG. Also the location of the InstaDMG source directory is set in the root level of the home directory – ~/InstaDMG
Bypassing the Registration Process
The package that bypasses the registration process can be downloaded here, ClearReg.pk which downloads as clearReg.dmg it is basically a script that will create 2 empty files in these locations:
/Library/Receipts/.SetupRegComplete /private/var/db/.AppleSetupDone
Just the presence of these files will bypass the installation registration processes and take the user straight to the login window.
– Expand the downloaded clearReg.dmg and move the contents “ClearReg.pkg” into the InstaDMG package repository:
~/InstaDMG/InstallerFiles/InstaUp2DatePackages/
Anything filed in here can be used to extend the functionality of the base image including script packages to full blown 3rd party application installs.
Create New User
To create a new user, InstaDMG comes bundled with an application called oddly enough “CreateLionUser.pkg” in your InstaDMG installation directory:
~/InstaDMG/AddOns/createUser/CreateLionUser.pkg
– Make a copy of this package and also file it in:
~/InstaDMG/InstallerFiles/InstaUp2DatePackages/
– Now we have to create the unique user by getting to the contents of the package, so in the copied user package control+click the package and “Show Contents” and navigate to and open in TextEdit or another simple text editor the following file:
Contents/Resources/userdata.plist
– The 2 key components that need to be configured are the shortname and the password, the shortname is entered in the string of the shortname key, in the instance below it is named admin (the default in the actual file is ‘lionuser’):
<key>shortname</key> <string>admin</string>
After entering the shortname save the file.
The password creation requires a trip to the terminal to create a hash so it’s not in clear text in the userdata.plist file.
– Launch Terminal from Applications/Utilities and cd into your CreateLionUser.pkg resources directory:
cd ~/InstaDMG/InstallerFiles/InstaUp2DatePackages/CreateLionUser.pkg/Contents/Resources
– and then run the hash command on the userdata.plist file like so::
./hash_lion_password.py userdata.plist
It will ask you for the password twice (if using symbols like @ surround the password in double quotes”p@ss!#ord”)- just enter it in and then the shadow hash is updated in the userdata.plist, save and close the file. A new password key with the hash is created in the userdata.plist file:
Other user values can also be set up in the userdata.plist file – see the ReadMe.txt in the AddOns folder of the InstaDMG install folder for what those values mean.
OK so that is the clearReg.pkg and CreateLionUser.pkg ready to be bundled in with the core base image.
Checksums and Catalogs
Checksums
The last two steps are creating checksums for the packages and then assigning the packages into catalogs to build the image. The checksum is a guarantee that the package is valid from its initial creation, and typically needs to be applied to the packages stored in the InstaUp2DatePackages directory :
~/InstaDMG/InstallerFiles/InstaUp2DatePackages/
The easiest way to do this in bulk is to run the checksum.py command on all the packages in InstaUp2DatePackages – the checksum.py command lives in ~/InstaDMG/Addons/InstaUp2Date/ – so:
cd ~/InstaDMG/Addons/InstaUp2Date/
./checksum.py ~/InstaDMG/InstallerFiles/InstaUp2DatePackages/* > checksums.txt
This will pipe the output of the checksum command to a file checksums.txt in the InstaUp2DatePackages directory – open that in TextEdit or vi or nano, the contents of the file need to be pasted into the new catalog.
You can also choose to run the “checksum.py” command without piping the output to a file, this way it will display verbosely in the terminal window – this can be handy for doing single checksums for later added packages. Just drag the package to the terminal window when running the checksum.py command. The checksum format will be like so:
CreateLionUser CreateLionUser.pkg sha1:83b4357037d82a254c5ef068c384e3fb2c1
Catalogs
The final piece is creating and adding these packages to a new catalog. Catalogs are plain text files and located in:
~/InstaDMG/AddOns/InstaUp2Date/CatalogFiles
There is a whole bunch of them, some are for specific hardware builds and different OSX versions these catalog files are responsible for building the image and can call on each other linking to customize the image build.
In this instance we are using the generic OSX 10.7 which is the “10.7_vanilla.catalog” but we need to add the 2 new packages to their own catalog which in turn then calls the 10.7_vanilla.catalog. In this instance the additional catalog is called LionExtras.catalog
You can call the catalog whatever you like just add the .catalog extension and file it in the path as above with the other catalogs the format needs to be like this:
# This is the catalog for the Addon LionExtras Settings - include-file: 10.7_vanilla.catalog Third Party Software: clearReg clearReg.pkg sha1:b0ba0f6bfd26956562e286bbcdfa8f78dd3722eb CreateLionUser CreateLionUser.pkg sha1:83b4357037d82a254c5ef068c384e3fb2c1
The first line is just a comment as indicated by the hash.
The second line calls for the “10.7_vanilla.catalog” to be run before this catalog.
The last 2 lines label the description of the package/the package name/checksum of the package – it is very important that these are tab separated not space separated eg:
/tab/clearReg/tab/clearReg.pkg/tab/sha1:b0ba0f6bfd26956562e286bbc…
Here is an example you can download.
The Build
Finally you can run the catalog command with sudo this will run the 10.7_vanilla.catalog first and then apply the LionExtras.catalog on top :
[~]: cd ~/InstaDMG/AddOns/InstaUp2Date/ [~]: sudo ./instaUp2Date.py -p LionExtras
The build process is output verbosely on the screen -in time an up to date image is spat out in the directory – “~/InstaDMG/OutputFiles/” named “10.7 Vanilla.dmg” which is the all encompassing new master image with the new user and clear registration files applied. Image a machine and test the login process with the new user.