Difference between revisions of "Firstboot Postflight Commands"

From AFP548 Wiki
Jump to navigation Jump to search
(No difference)

Revision as of 16:15, 1 September 2010

#!/bin/sh

# Standard settings for images.
# Script is meant to be run as a postflight script in a .pkg file. Also installs startup settings script as a Launchd item which is inside the package /Contents/Resources directory.

##### Begin Declare Variables Used by Script #####

# Declare 'defaults'and 'PlistBuddy'.

defaults="/usr/bin/defaults"
PlistBuddy="/usr/libexec/PlistBuddy"

# Declare directory variables.

PKG_DIR="$1/Contents/Resources"
SCRIPTS_DIR="$3/Library/Scripts/CompanyName"
LAUNCHD_DIR="$3/Library/LaunchDaemons"
PRIVETC_DIR="$3/private/etc"
PREFS_DIR="$3/Library/Preferences"
USERPREFS_DIR="$3/System/Library/User Template/English.lproj/Library/Preferences"
NONLOC_USERPREFS_DIR="$3/System/Library/User Template/Non_localized/Library/Preferences"
ROOT="$3/"
UPDATE_DYLD="$3/usr/bin/update_dyld_shared_cache" # Set variable to location of update_dyld_shared_cache command on target volume.

##### End Declare Variables Used by Script #####

##### Begin Preference Setting #####

# These settings can be set on the target volume before startup.

# Run update_dyld_shared_cache
$UPDATE_DYLD -universal_boot -root $ROOT

# Display login window as Name and Password.
$defaults write "${PREFS_DIR}/com.apple.loginwindow" SHOWFULLNAME -bool YES

#Starts the Flurry screensaver over the login window when idle for 60 seconds
$defaults write "${PREFS_DIR}/com.apple.screensaver" loginWindowIdleTime -int 60
$defaults write "${PREFS_DIR}/com.apple.screensaver" loginWindowModulePath "/System/Library/Screen Savers/Flurry.saver"

# Sets autologout to 60 minutes and enables it
$defaults write "${PREFS_DIR}/.GlobalPreferences" com.apple.autologout.AutoLogOutDelay -int 3600

# Use encrypted virtual memory.
$defaults write "${PREFS_DIR}/com.apple.virtualMemory" UseEncryptedSwap -bool Yes

# Set Safari Preferences.
$defaults write "${USERPREFS_DIR}/com.apple.Safari" HomePage http://www.google.com/
$defaults write "${USERPREFS_DIR}/com.apple.Safari" ShowStatusBar -bool YES

# Set Finder Prefereces.
$defaults write "${USERPREFS_DIR}/com.apple.finder" ShowMountedServersOnDesktop -bool YES

# Enables Double Click Title bar to Minimize Window

$defaults write "${NONLOC_USERPREFS_DIR}/.GlobalPreferences" AppleMiniaturizeOnDoubleClick -bool TRUE

# No .ds-store files on Network Shares
$defaults write "${PREFS_DIR}/com.apple.desktopservices" DSDontWriteNetworkStores true

# Globally Set Expanded Print Dialouge Box.
$defaults write "${PREFS_DIR}/.GlobalPreferences" PMPrintingExpandedStateForPrint -bool TRUE

# Use short-name for logging into Network Shares
$defaults write "${PREFS_DIR}/com.apple.NetworkAuthorization" UseDefaultName -bool NO
$defaults write "${PREFS_DIR}/com.apple.NetworkAuthorization" UseShortName -bool YES

# Set Apple Mouse button 1 to Primary click and button 2 to Secondary click.
$defaults write "${USERPREFS_DIR}/com.apple.driver.AppleHIDMouse" Button1 -integer 1
$defaults write "${USERPREFS_DIR}/com.apple.driver.AppleHIDMouse" Button2 -integer 2

# Disable Time Machine Offers.
$defaults write "${PREFS_DIR}/com.apple.TimeMachine" DoNotOfferNewDisksForBackup -bool YES

# Disable Time Machine AutoBackup
$defaults write "${PREFS_DIR}/com.apple.TimeMachine" AutoBackup 0

# Enables SSH
$PlistBuddy -c "Delete Disabled" $3/System/Library/LaunchDaemons/ssh.plist

# Allows any user to set dvd region
$PlistBuddy -c "Set :rights:system.device.dvd.setregion.initial:class allow" "$3"/etc/authorization

# Firewall Settings | 0 = Off | 1 = On For Specific Services | 2 = On For Essential Services
$defaults write "${PREFS_DIR}/com.apple.alf" globalstate -int 0

##### End Preferences Setting #####

exit 0