rsync remote host syntax

12 03 2013

In a nutshell:

rsync -v -r -u -e ssh ./localsource netid@server.domain.url:/remote/destination

-v = verbose
-r = recursive
-u = update changed files only
-e = specify remote shell (“ssh” in this example)

You can also get a “dry run” and see what will change (but not actually execute the change) by adding the -n flag:

rsync -v -r -u -n -e ssh ./localsource netid@server.domain.url:/remote/destination

Files that should regularly be excluded (such as .DS_Store) can have their names added to a text file, such as:

Temporary Items
.DS_Store
skip.txt

Then call the text file with the --exclude-from flag:

rsync -v -r -u -e ssh --exclude-from=/path/to/skip.txt ./localsource \ netid@server.domain.url:/remote/destination





Signing Apple Software Packages for GateKeeper

12 02 2013

Using the Apple Developer certificates (obtained via XCode or through developer web site):

productsign --sign "Developer ID Installer: [name]" --keychain /Library/Keychains/System.keychain --cert "Apple Code Signing Certification Authority" /path/to/existing.pkg /path/to/newly/signed.pkg

Update 2014-05-21: Apparently with Mavericks you don’t need to specify the intermediate certificate, I guess? Anyway, this works better:

productsign --sign "Developer ID Installer: [name]" --keychain /Library/Keychains/System.keychain /path/to/existing.pkg /path/to/newly/signed.pkg





Creating a DMG wrapper from the command line

6 03 2012

Because I always seem to forget the command when I need to make one:

hdiutil create -srcfolder /path/to/theSource.pkg /path/to/theDestination.dmg





Disable iCloud popup on first user login

15 12 2011

OS X 10.7.2 introduced iCloud, and with it came an automatic setup prompt on first user login.  Given all the legal compliance we have regarding data security we wanted to discourage faculty and staff from storing university data on iCloud (we have local servers for that). However, since we don’t directly manage client machines or have any control over what clients should or should not do with their computer (even if it is university-owned), I needed to find a way to discourage use of iCloud but not disable it completely.  The compromise was to suppress the setup prompt pop-up but still allow manual setup of iCloud if desired.

The MacAdmin community rallied and supplied a documented method for disabling the pop-up, however this method only seems to work in managed environments and is negated when Setup Assistant runs on first boot.  DeployStudio included a method of disabling the iCloud pop-up with build 1.0rc130, but only as part of their ds_finalize script on post-deployment reboot, which we bypass as part of our thin imaging method.

After several false starts and failed experiments, I devised this combination of a couple of launchdaemons — one to rename the iCloudPref.prefPane file (preventing Setup Assistant from launching it) and one to rename it back to its original file name — and a launchagent to trigger the second daemon after first login.  The daemons, agent, script files and any custom directories used are installed via package as part of a DeployStudio workflow.

Here’s the first launchdaemon to kick it all off, located in the /Library/LaunchDaemons directory. In this example the script it calls is located in /private/var here but you could put it anywhere root can access:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>edu.uvm.iCloudSuppress-daemon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/sh</string>
		<string>/private/var/iCloudSuppress-daemon.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

 

The called script renames the iCloud.prefPane file, deletes the daemon, then self-destructs. At first I tried to include an unload of the daemon in here too, but unloading the daemon seemed to halt the script prematurely before it could self-destuct and was therefore left out:

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH

# rename iCloud PrefPane
mv "/System/Library/PreferencePanes/iCloudPref.prefPane" "/System/Library/PreferencePanes/iCloudPref.uvm_backup"

# remove daemon
rm -f "/Library/LaunchDaemons/edu.uvm.iCloudSuppress-daemon.plist"

# script self-destruct
srm $0

 

The second launchdaemon (also installed to /Library/LaunchDaemons) loads but waits for a signal from the post-login launchagent before running its script. In this example it watches for changes in the /Users/Shared/UVM-Setup directory but you could have it watch any directory that is writable by any local account and is not subject to change by other processes. As above, the script it calls is located in /private/var here but you could put it anywhere root can access:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>edu.uvm.postassistant-daemon</string>
	<key>OnDemand</key>
	<true/>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/sh</string>
		<string>/private/var/postassistant-daemon.sh</string>
	</array>
	<key>RunAtLoad</key>
	<false/>
	<key>WatchPaths</key>
	<array>
		<string>/Users/Shared/UVM-Setup/</string>
	</array>
</dict>
</plist>

 

The launchagent is installed to /Library/LaunchAgents and loads on first login. In this example the agent script is located in the /Users/Shared/UVM-Setup directory, same as the watched directory of our second launchdaemon. Again, you could put the script anywhere the user has read/write access to but since we’ll be recursively removing the /Users/Shared/UVM-Setup directory completely anyway it’s one less thing to remember to remove later:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>edu.uvm.postassistant-agent</string>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/sh</string>
		<string>/Users/Shared/UVM-Setup/postassistant-agent.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

 

The launchagent script touches the directory watched by the second daemon (thereby initiating its script, as root) and self-destructs:

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH

# make a change to /Users/Shared/UVM-Setup to trigger launchd that can run as root
touch "/Users/Shared/UVM-Setup/runthatbaby"

# script self-destruct
srm $0

 

Lastly, the second launchdaemon script restores the iCloudPref.prefPane file name, deletes the remaining launchagent and launchdaemon files and the OnDemand trigger directory, then self-destructs:

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH

# restore iCloud PrefPane
mv "/System/Library/PreferencePanes/iCloudPref.uvm_backup" "/System/Library/PreferencePanes/iCloudPref.prefPane"

# remove agent
rm -f "/Library/LaunchAgents/edu.uvm.postassistant-agent.plist"

# remove daemon
rm -f "/Library/LaunchDaemons/edu.uvm.postassistant-daemon.plist"

# delete watch directory
rm -rf "/Users/Shared/UVM-Setup"

# script self-destruct
srm $0

 

When all is said and done, clients should finish Setup Assistant with no subsequent iCloud pop-up but can still manually open System Preferences and set up iCloud later if desired.





Apple KB#HT2674: Intel-based Mac: Startup sequence and error codes, symbols

15 12 2011

This Apple KB article demystifies what those startup symbols mean and what can cause them to appear:

Startup Sequence stage Event
Power On Boot-ROM/RAM check is initialized
BootROM-POST
  • Black screen, power LED on – POST or BootROM failure
  • Flashing power LED once per second – bad RAM, no RAM
  • Three flashes, a pause, and three more flashes (occurs continuously) – marginal RAM
BootROM-EFI Boot chime
Boot EFI
  • Metallic Apple – found boot.efi
  • Circle with Slash – could not load boot.efi, or some other issue
  • Flashing globe – looking for booter/kernel on netboot server
  • Metallic Apple with spinning earth below – found booter/kernel on netboot server
  • Broken Folder that blinks – no bootable device has been found
kernel Grey screen with Metallic Apple and spinning gear
launchd Blue screen
loginwindow Login window appears
User Environment Setup The text "Logging in…" appears in login window along with a progress bar. Upon successful login, the Desktop and Dock appear.







Skip to toolbar