Posts tagged with “”

MacPorts, MySQL 5 and the Launch Daemons

Update, 7/29/2009: In response to my question about this on StackOverflow, Mike Richards offered an infinitely better solution. Apparently MacPorts is effectively deprecating the mysql5 +server path in favor of a new mysql-server package. I can’t confirm this personally, but it sounds reasonable enough.

That sounds a little bit like a Harry Potter title, but the content isn’t nearly as entertaining. For the past year or two, I’ve been using a MySQL installed via MacPorts, the (pseudo-) apt repository for Mac ports (get it?) of Unix applications and utilities. MacPorts has been fantastic and I haven’t regretted the decision to move away from either OS X’s native MySQL install or from MAMP, an all-in-one solution that I had used previously. The last few times I’ve installed MySQL, though, I’ve noticed that I haven’t been able to get MySQL to start automatically when I login.

Following Chad Kieffer’s excellent tutorial for installing & configuring a MacPorts MySQL install, I would get myself to the point where I execute launchctl to load the plist file that will start MySQL automatically:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Unlike Chad, I want MySQL to start automatically. Admittedly, my work-life balance sucks; I’m more than likely doing something work-related if I’m sitting behind the keyboard. Given that, the server might as well be ready to respond, right? Except that the plist I’m trying to load…isn’t there to be loaded.

The first time that I did the install, the plist was there and loaded as expected, but the last 2 or 3 times that has not been the case. I don’t know what changed with the MacPorts bundle, but that plist simply isn’t there. Fortunately, I still have my old install around, so I faked it.

If anyone else is having the same issue, here’s how you too can fake it:

  1. Create a directory for the launch scripts.
    $ mkdir -p /opt/local/etc/LaunchDaemons/org.macports.mysql5
  2. Download the files that no longer get installed, mysql5.wrapper and org.macports.mysql5.plist. I’m making mine available since I don’t know where else to get them. Save both files to the directory you just created.
  3. Set the proper ownership and permissions.
    $ sudo chown root:wheel /opt/local/etc/LaunchDaemons/org.macports.mysql5/*
    $ sudo chmod 755 /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper
    $ sudo chmod 644 /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist
  4. Create a soft link to the newly downloaded plist file in /Library/LaunchDaemons.
    $ cd /Library/LaunchDaemons
    $ ln -s /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist org.macports.mysql5.plist
  5. Load the plist file, as indicated in Chad’s instructions and duplicated above. For the sake of keeping it all in one place:
    $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
  6. Reboot.
  7. Verify that MySQL has started.
    $ sudo ps -ef | grep mysql

You should see output that looks something like this:

    0    65     1   0   0:00.00 ??         0:00.00 /opt/local/bin/daemondo --label=mysql5 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart ; --pid=none
    0    85     1   0   0:00.01 ??         0:00.01 /bin/sh /opt/local/lib/mysql5/bin/mysqld_safe --datadir=/opt/local/var/db/mysql5 --pid-file=/opt/local/var/db/mysql5/rob17.local.pid
   74   111    85   0   0:07.48 ??         0:19.75 /opt/local/libexec/mysqld --basedir=/opt/local --datadir=/opt/local/var/db/mysql5 --user=mysql --pid-file=/opt/local/var/db/mysql5/rob17.local.pid --socket=/tmp/mysql.sock
  501  3370  3145   0   0:00.00 ttys003    0:00.00 grep mysql

If you do, then you’re golden. If you don’t, then you probably made a mistake. If the mistake is mine, please let me know in the comments and I’ll make the appropriate adjustments.

SSH Host Key Checking

One of the things that’s always annoyed me, but not to such a degree that I’ve felt compelled to expend any effort “fixing” it, is the prompt that I get every time I SSH to a machine that I haven’t connected to before. It looks a little something like this:

The authenticity of host 'host.domain.tld (192.168.1.16)' can't be established.
RSA key fingerprint is 58:3d:dc:39:b3:5c:44:0b:ah:9b:7d:01:8e:f2:f8:77.
Are you sure you want to continue connecting (yes/no)?

Because it’s not a huge deal to type “yes” to create the connection, I’ve never cared enough to really look into it.

This morning, though, I was trying to do a pull from one of my git repositories only to find that the server signature had changed and my connection was terminated. As far as I know, the only way to re-establish a connection terminated for this reason is to remove that server from my list of known hosts. To do so I usually crack open my ~/.ssh/known_hosts file, find the line that begins with the host name of the server I’m trying to connect to and delete that line. The next time I try to connect, the server is added back to the file (after typing “yes” again).

Unfortunately, I was working on my Linux machine this morning and I got an unpleasant surprise when I opened my ~/.ssh/known_hosts file. Ubuntu, unlike every other Unix flavor I’ve worked with/in, encrypts the contents of that file. That meant I couldn’t find the line for the particular server whose signature changed for the purpose of surgical deletion. To reset that server as a known host, I’d have to delete the entire contents of the file. I connect to a number of servers and this has become a big file; I didn’t want to have to type “yes” that many times so a “fixing” the annoyance took on a greater urgency.

This is when it’s really handy to work with a Linux sys admin. He heard me expressing my annoyance in a semi-colorful manner and told me to just shut off the authentication prompt. Hearing the ability to kill two birds with one stone, I did a quick search, then cracked open my SSH config file (/etc/ssh/ssh_config) and edited the following line:

# StrictHostKeyChecking ask

I uncommented the line and changed the value to “no” and I’m no longer prompted when connecting to new machines. Now it’s safe to clear my known_hosts file without bother. I do still get a warning that a new host has been added to my file (which is nice), but no interaction is required.

Make Linux Just a Little Sexier

Granted, I’m a Mac user, at least at home, but I like to think I’m not a total fanboy. When I moved to Linux at work and began customizing my machine, I saw countless recipes with instructions for skinning Linux to look like a Mac (or maybe there’s just one and everyone in the free world is linking to it). I don’t get that. Linux isn’t a Mac. A penguin in a tux is still a penguin, right? The fact is, I like my operating systems to look like what they are and, besides, I’ve never had much luck with Linux themes. There’s always something that gets left out and kind of ruins the whole effect.

The honest truth is, I kind of like the Linux aesthetic. Most of it, anyway. I’m not, however, a fan of the default fonts and I thought that installing Mac fonts might be just the thing to dress up the penguin without overdoing it. Turns out that they are.

Try it. Here are my settings:

My Ubuntu font settings

Set or Change the Greasemonkey Script Editor

In my life, particularly my technical life, there are a number of things that I do regularly, but not frequently. A consequence of the lack of frequency (or maybe of getting older) is the inability to remember exactly what I did to accomplish the task successfully the last time I did it. A consequence of the regularity is that my inability to remember annoys me. I know I’ve done it, I just can’t remember how.

One of those things that I need to do regularly, but infrequently, is edit Greasemonkey scripts for Firefox. All too often, I select Tools > Greasemonkey > Manage User Scripts > [Script I Want to Edit] > Edit only to be seized by that familiar paralysis that is normally reserved for trips to the refrigerator when nothing happens.

I know exactly why nothing happens, I just can’t remember how to fix it. Fortunately, that’s what blogs are for, so here are the steps to set (or update) the default editor for Greasemonkey scripts:

  1. In the Firefox address bar, type about:config and press Enter.
  2. In the Filter input, type greasemonkey.editor.
  3. If the preference exists, just double click on the preference name and, in the popup, enter the file path of the preferred editor.
  4. If the preference does not exist, right click in the preference list and select New > String. When prompted for the preference name, type greasemonkey.editor and press OK. At the next prompt, enter the file path of the preferred editor.

Rethinking the Taskbar

Over the last couple of weeks, I’ve noticed something about how I’ve organized my desktop: it no longer includes a taskbar. And, although it’s one of those computing metaphors that been around forever and seems timeless, obvious and necessary, I don’t miss it at all. In fact, I really like not having it around.

The taskbar, as it exists by default (but with variances) in each of the three operating systems that people talk about when they talk about operating systems, exists to serve three primary purposes:

  1. Application launcher
  2. Window manager
  3. Notification area

What I’ve gradually realized is that the only capability I really need and use is the notification area. The other two concerns are better handled, I think, in other ways.

Application Launcher

In the interest of full disclosure, I’ll admit that I keep this functionality around on my desktop, but only in the interest of fallback. Except in the case of emergency, I used a third party key-based application launcher that is unobtrusive and more productive for me. My choices: Quicksilver (Mac), GNOME Do (Linux) and Launchy (Windows).

There’s no escaping the fact that a few key taps is easier and faster than wading through layers of nested menus.

Window Manager

The window manager is the visual metaphor that indicates which applications are running and/or which windows of a given application are open. On Mac, this is a function of the dock, on Linux it’s a panel accoutrement that can be added or removed like every other panel option and on Windows it’s that middle area of the taskbar between the Start button and the system tray (now called the notification area). But why do we need it?

Once I noticed that I’d effectively removed it from my consciousness, I started thinking about why. The fact is that I already know what windows are open when I need to know. At any given time, only one window is, and can be, active. If I need another application or window, I use the keyboard-based task switcher to access that application or window. On a Mac, that’s Cmd+Tab to switch applications and Cmd+` to switch between windows of the active application. On Windows and Linux, Alt+Tab does both. In order to switch tasks, the task switcher includes a display of the other applications or windows that are open.

In my mind, the only time I need to know what other applications and windows are available to me are when I no longer want the one that’s currently active. At that time, I’m using the task switcher anyway, so the constant visual cue on the taskbar is actually just visual clutter.

Customizing the Desktop

Unfortunately, removing the window manager and application launcher isn’t possible on Windows, but I no longer use Windows on a regular basis and it is possible, at least superficially, on both Mac and Linux.

Mac

Mac separates the three purposes of the taskbar nicely for me. The application launcher and window manager are contained within its dock while the notification area exists on the menu bar. I can’t remove the dock without doing some potentially detrimental system-level hacking, but I’ve set it to auto-hide and moved it to the left of my desktop where I’m less likely to hover over it and make it display. Although it’s still around and available, I haven’t used the dock in a very long time.

Linux

Linux, or more accurately, the Gnome desktop environment that I prefer, does an even better job of separating these concerns. Gnome uses a panel metaphor on which the user can place different functional components. My desktop includes a single panel at the top of my screen that looks a lot like my Mac menu bar. It contains my application launcher – as I’ve admitted, I do keep it around just in case – and my notification area, but no window manager.

← Earlier Posts Page 1 of 3