dockutil 1.1.2 released
Posted: May 26, 2012 Filed under: Python, Deployment, Mac OS X, Unix, Scripting, dockutil | Tags: dockutil, dock, package, version, update Leave a comment »No feature changes, just a few bug fixes:
- fix issue with replacing a url dock item
- add legacy support –hupdock option for backward compatibility
- fix paths with spaces when passing full path to plist
https://github.com/downloads/kcrawford/dockutil/dockutil-1.1.2.pkg.dmg
Fix for Sign out of Mac AppStore
Posted: February 17, 2012 Filed under: Mac OS X, Unix | Tags: appstore, gray, grey, login, signin, signout, storeagent Leave a comment »A few times I’ve had issues with signing in or out of the Mac AppStore. The sign out may be greyed out or the login sheet does nothing.
After removing the related preferences noted elsewhere and verifying that my Apple ID billing info was okay, I did not want to log out or reboot. Killing the storeagent got things working again for me. (It is a LaunchAgent, so it will start back up again.)
In Terminal:
killall storeagent
Then try sign in to the Mac AppStore again.
dockutil 1.1 released
Posted: February 5, 2012 Filed under: Deployment, dockutil, Mac OS X, Mac OS X Server, Python, Scripting 6 Comments »Version 1.1 of dockutil is out:
- fixes many issues with paths (should now work with Default User Template and other paths with spaces)
- adds option to not restart the dock (–no-restart)
- fixes issue where item would be added multiple times (use –replacing to update an existing item)
- resolves deprecation warnings
- adds option to remove all items (–remove all)
- fixes issue with removals when a url exists in a dock
- adds option –version to output version
Snow Leopard Apache Web Server SSL Pass phrase Error
Posted: November 29, 2011 Filed under: http, Mac OS X, Mac OS X Server, Unix | Tags: apache, key, Pass phrase incorrect, Snow Leopard, ssl Leave a comment »If you are getting errors “Pass phrase incorrect” in your apache logs on Snow Leopard server, it is because the key is protected by a password. I found the answer here.
The password for the key is stored in the System Keychain. It is a password entry called “Mac OS X Server certificate management”. You can open the entry and select “Show Password”. You may also use the security command line tool to dump the password.
security find-generic-password -l "Mac OS X Server certificate management" -g
or
security dump-keychain -d # look in data for password which will look like a GUID
Once you have the password, you can create a copy of the key without the password using openssl:
openssl rsa -in /etc/certificates/server.domain.com.uniqueid.key.pem \ -out /etc/certificates/server.domain.com.uniqueid.passwordlesskey.pem
You can then replace the password protected key with the passwordless key or point apache to the passwordless key in your /etc/apache2/sites/sitename.conf file.
Tips for writing command line tools in ruby
Posted: August 2, 2011 Filed under: Mac OS X, Ruby, Scripting, Uncategorized, Unix | Tags: command line, development, exit status, file extension, irb, load, option parsing, require, require ruby file without extension, Ruby, tool Leave a comment »- Option parsing: Read this article by Allen Wei on RubyLearning Blog for a great overview. I recommend sticking with the built-in OptionParser if you want to reduce dependencies.
- If you want your code to be loadable so you can access functions and classes in the irb console for testing, use the following pattern:
def main#option parsing and execution code hereendif __FILE__ == $0main()endThis way the main function will only be automatically called if the script is being executed on the command line.
And in irb, you can call your functions and classes as you see fit for testing without triggering your whole script to run.Note that this is similar to the python __main__ test if you are coming from a python background.
- Naming without ruby’s.rb extension: You can name your executable without the rb extension if you wish, just be sure to include your shebang (#!)
To use the user’s default ruby, use:
#!/usr/bin/env ruby
But in some cases you may want the specify the path to ruby so you can use macruby or rubycocoa if you are need those frameworks to be available
#!/usr/bin/ruby
When testing in irb,
require 'script-name'
won’t work without the rb extension, but
load 'script-name'
does work. - Use exit codes. When your script fails or needs to communicate status at exit, use standard exit status codes.
Exit zero for default success status
exit 0
Exit any other number for a failure or warning status. You choose the exit codes for your tool, but be sure to document them if they require more explanation than simple success or failure.
exit 27 - Output to stderr using:
$stderr.puts "error: problem ...."
Parsing Mac OS X System Profiler
Posted: February 4, 2011 Filed under: Deployment, Hardware, Mac OS X, Mac OS X Server, Scripting, Unix | Tags: Apple Remote Desktop, ARD, Asset Collection, Facter, hardware, parse, plist, Puppet, report, sysinfocachegen, System Profiler, system_profiler 3 Comments »It is pretty cool how Apple System Profiler has a command line equivalent (system_profiler). And it is pretty cool how system_profiler has a -xml option to allow for easier parsing. You might use this info for extracting asset information into a database or for puppet facter facts.
However if you’ve ever looked at that xml, you know that it is a tree full of unpredictable semi-structured data that was designed specifically for the GUI app. So even though you can parse it with your favorite plist parser, there is still a lot more work to do to get to the data you care about.
The tree structure is nice for a browsing through on a single machine, but not so good for reporting across many machines.
Apple stores most of the same data as key value pairs in its database for ARD reporting, but they do a lot of massaging of the data to get it that way.
It is possible to get at this data in an ARD database if you have an ARD collection server, but an ARD collection server isn’t for everyone and doesn’t serve every use case.
You can still get at the nicely formatted ARD information. ARD client includes a tool that outputs most, if not all of the asset information you care about in a much nicer structured format for reporting.
The tool is called sysinfocachegen and you use it like this:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/sysinfocachegen -p /tmp/com.yourorganization.systeminfo.plist
Just use your favorite language’s plist parser to read the plist.
Quickly Calculate size of radmind Transcript Payload
Posted: May 13, 2010 Filed under: Deployment, Mac OS X, Scripting, Unix | Tags: radmind, grep, transcript, size, awk, sum 1 Comment »grep ^[af] /var/radmind/transcript/transcript_name.T | awk ‘{sum = sum + $7} END {print sum/1000}’
Every line that starts with “a” or “f” is a file. Sum up the size field. Divide by 1000 to get KB.
Customizing the Cisco or IPSec VPN client in Snow Leopard
Posted: October 1, 2009 Filed under: Mac OS X, Unix | Tags: 10.6, Cisco, IPSec, racoon, Snow Leopard, VPN 9 Comments »The Snow Leopard VPN is not very configurable from the GUI, but behind the scenes it is using a racoon configuration.
To grab the configuration it is generating, configure the VPN in the System Preferences GUI, then rename /usr/sbin/racoon and try connecting. The config file will be written in /var/run/racoon/. Grap a copy of that file and customize it to your needs. Once you have the config file, rename racoon back to its original name.
Then to make the GUI use your custom config file instead of the one it generates, edit /etc/racoon/racoon.conf to include your custom config file and comment out the line:
include "/var/run/racoon/*.conf" ;
By making a few changes I was able to get a successful connection to our Cisco VPN Concentrators.
I’m hoping there is a less hacky way to accomplish this. If you know of one, let me know. Otherwise file a bug with Apple.