Archive for March, 2005

Computer Lists and Workgroup Manager

Saturday, March 26th, 2005

The other day it was looking like we might have to bite the bullet and actually put every single one of our clients into Computer Lists in Workgroup Manager…
The horror… with no way to easily import the computers (or export for that matter), we weren't really looking forward to having to enter all those addresses by hand…

Anyway, after remembering when the Computer Lists got all out of whack and I had to manually fix up the LDAP directory, I was thinking it might be good to put together a tool that let you:

  • Import computers/lists, with decent duplicate handling.
  • Export lists altogether or individually.
  • Verify the consistency of your Computer Lists.

Anyway, I wonder what the best way to handle this is in a Cocoa app? straight C ldap functions? DirectoryServices.framework? hmmm….

Sure you can use dsimportexport to import Computer records, but I'm not particularly happy with that tool… and it gets to be a pain when you can't overwrite entries, especially when you get a lab machine's motherboard replaced…

Posting mail to mailboxes directly with Cyrus.

Monday, March 21st, 2005

So if you've followed Joel's excellent article on installing cyradm to manage Cyrus, you might find you want to be able to send email directly to shared mailboxes.

Some mail clients bork out on the default setting, so I've done this:

add this line to /etc/imad.conf

postuser: postuser

Use cyradm to create a shared mailbox, and assign “anyone” the “p” privilege, like this:

localhost> create MySharedMailbox
localhost> setacl MySharedMailbox anyone p

Restart the IMAP server, and you can then address mail to:

postuser+MySharedMailbox@my.server.address

and it will automatically be delivered straight to that folder.

I use this for Quarantine-Virus, Quarantine-Spam folders that let the IT staff see what mail is being rejected for what reason, as we don't send alerts for spoofing viruses.

dsimportexport is broken # 2

Monday, March 21st, 2005

So there's another thing broken with dsimportexport apart from not overwriting properly.

If you are importing users, and you're not specifying the uid value, Workgroup Manager picks quite a sane value for the uid for that user.

dsimportexport on the other hand, seems to just pick really huge numbers that have no relation to reality, so you need to construct this manually.

In php, I'm doing it with something like this:

function get_next_uid()
{
        $nextuid_conn = ldap_connect("my.od.master.server");
        ldap_set_option($nextuid_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
        ldap_start_tls($nextuid_conn);
        $nextuid_bind = ldap_bind($nextuid_conn);
        if (! $nextuid_bind) { return false; }

        $nextuid_search = ldap_search($nextuid_conn,  "cn=users,dc=myorg,dc=au "(uid=*)", array ("uid","uidnumber"));
        $nextuid_info = ldap_get_entries($nextuid_conn, $nextuid_search);
        $current_uids = array();
        foreach ($nextuid_info as $this_nextuid)
        {
                $current_uids[] = $this_nextuid[uidnumber][0];
        }
        sort($current_uids);
        $the_next_uid = ( array_pop($current_uids) + 1);
        return $the_next_uid;
}

So when you're importing a bunch of users, call this to work out the next available uid.

Split mail by month in AppleScript and Mail.app

Sunday, March 20th, 2005

So my resurgent affair with AppleScript continues…
I was having to organise a fair bit of email, so came up with this AppleScript to split email by month.

This doesn't look at the year at all. You need to organise that on your own.

Basically it just takes the list of currently selected mailboxes in the front most window of Mail.app, and for each one, it creates a corresponding “[mailbox-name]-SplitByMonth” mailbox locally, and sub-folders for each month.

Save it to one of the Mail Scripts folders, ie ~/Library/Scripts/Mail Scripts/ and then use it from within Mail.app

using terms from application "Mail"
	display dialog ¬
		"This will split the currently selected mailboxes in the frontmost Mail.app window
		to new mailboxes by month." buttons {"Cancel", "Split Mailboxes"} ¬
		default button "Split Mailboxes"
	set splittingMailboxList to selected mailboxes of front message viewer
	repeat with splitThisMailbox in splittingMailboxList
		set shortMonthlist to {"01-Jan", "02-Feb", "03-Mar", "04-Apr", "05-May", "06-Jun", ¬
			"07-Jul", "08-Aug", "09-Sep", "10-Oct", "11-Nov", "12-Dec"}
		set fullMonthList to {"January", "February", "March", "April", "May", "June", "July", ¬
			"August", "September", "October", "November", "December"}
		set parentMailboxName to (name of splitThisMailbox) & "-SplitByMonth"
		tell application "Mail"
			try
				make new mailbox with properties {name:parentMailboxName}
			end try
			set mailboxMessages to every message of splitThisMailbox
			repeat with eachMessage in mailboxMessages
				set receievedDate to (date received of eachMessage) as string
				set monthIndex to 1
				repeat with eachFullMonth in fullMonthList
					if (receievedDate contains eachFullMonth) then
						set monthMailboxName to parentMailboxName & ¬
							"/" & (name of splitThisMailbox) & ¬
							"_" & (item monthIndex of shortMonthlist)
						try
							make new mailbox with properties {name:monthMailboxName}
						end try
						move eachMessage to mailbox monthMailboxName
					end if
					set monthIndex to monthIndex + 1
				end repeat
			end repeat
		end tell
	end repeat
end using terms from

Analog is the new Digital ?

Sunday, March 13th, 2005

So the Hipster PDA and the whole Getting Things Done system seems to be popping up absolutely everywhere these days.

I have say I'm kind of enthused about it, maybe because it kind of fits how I organise my email life, and perhaps everything else could do with a similar system…
The OS X Inventories list is useful, it has a lot of the apps I'm fond of, and the email tips are useful, apart from the auto-check one. I need five minute windows at the most on server alerts, or staff bringing a problem to my attention.

I sure couldn't live without Butler or Quicksilver anymore. They've become so indispensable I'm even considering buying LaunchBar now…

Configuring Tomcat under OS X Server for more memory…

Sunday, March 6th, 2005

So after I hit somewhere in excess of 850 COFA Student blogs on blojsom (we're well over 1000 now, be interesting to see how many of them actually start using it…), I started running into problems with the amount of memory Tomcat was using by default.

On your standard Tomcat install, you'd increase the memory settings with something like:

JAVA_OPTS="-Xms128M -Xmx512M"

to set the minimum and maximum memory footprint, and you'd do this at your 'catalina.sh' file, which on OS X Server is in /Library/Tomcat/bin/catalina.sh

The problem here is that this file isn't what is actually called when you do stuff like:

serveradmin start appserver

only if you call catalina.sh directly like:

/Library/Tomcat/bin/catalina.sh start

which means you need to faff around if you have to reboot the server.

Anyway, some digging around found this file, which is what serveradmin uses to start/stop the appserver service.

/usr/share/servermgrd/bundles/servermgr_appserver.bundle/Contents/Resources/run.sh

which essentially contains the same stuff as catalina.sh if you're just running Tomcat in standalone mode and not using JBoss at all.

This will probably get wiped out in software updates, but at least I don't have to come up with some clunky startup item which stops the appserver service and starts it again via catalina.sh.

Be nice if we could customize these settings somewhere without having to worry about this though.