Archive for January, 2007

To Linux / Open Source Advocates

I just read another linux advocacy article off of reddit, in this case Five Reasons why Linux will eventually rule the world, and it hit a lot of my pet peeves about these kinds of articles. In a nutshell, for users, all that matters is that their work gets done, and all other arguments are wasted bits.

I have a few suggestions for open source / linux advocates:

  1. Don’t mention Microsoft
    Just don’t do it. My friend Nathan has a set of trolls, and regularly downmods anything referring to those in any setting (slashdot, reddit, what-have-you), and for you linux advocates, Microsoft should enter your troll-sphere. I’ve heard that any press is good press, and while that might not be true (ask Bush about Iraq), I do know that zero press is zero press. I also believe that branding-advertiso-brainwashing works (ask deBeers), so do everyone a favor and not mention the “competition”. At this point the fact that Microsoft exists is almost a non-issue to you. You solve all your problems without Microsoft products, so they are about as relevant to you as vitameatavegamin.
  2. Don’t mention intangibles
    For most people, the choice of operating system or office suite has nothing to do with freedom, morality, or elegance of the code. It’s a non-issue for non-techies, and a dead end for advocates. Technical folks can look all that up, and understand the advantages / disadvantages, but you don’t need to convince them. You need to convince the non-technical CEOs and managers who believe that using open source takes money from their pocket. I run into people in the course of my job who have little to no to false understanding of what “open source” really means. I’d guess half the CEOs in the country think that their codebase is their competitive advantage, and if they employ open source then competitors will steal their business. They will not be convinced by tirades about liberty.
  3. Blog your solutions
    Get a blogger account, and start blogging how you solved your problems using linux or open source. Please, don’t plan to run your own server from your apartment with your hand-rolled Erlang blog engine, cause you’ll never get to it. Just go ahead and start the blogger account with the crappy template that doesn’t use CSS classes the way you’d prefer. When people google to solve their problem, you want there to be multitudes of open source solutions clogging the results. This mostly already happens, but more content can’t hurt, and I’m curious how many dead accounts blogger will keep hosting.
  4. Appeal to the wallet
    In case you haven’t realized it, money makes the world go round. That will remain the case until the either the zombies or the aliens arrive, and then we’ll have a brief respite while exchange rates re-adjust. When people ask why they should use open source, the answer needs to be “because it saves you money”. Last week alone using Firefox with Firebug saved me probably 12 hours worth of time in debugging javascript and reverse-engineering colors and styling from a mock-up. That sort of productivity gain gives managers and CEOs a high equivalent to 3 whippets. Time and cost savings need to be a main point in any article designed to convince someone to switch.
  5. Focus on the user benefit
    Users care about how they benefit. That’s it. I feel this Gimp vs Photoshop article is a good example of open source advocacy. It’s focused on what benefits differentiate the two, and concludes:

    I know I’ve beat the horse to death, but unless you want to pirate software, there is no reason to use Photoshop if you’re not producing a print publication – use the Gimp.

    That is the essential message to send: “Unless you want to (increase cost | increase risk | break the law | behave irrationally), use the open source equivalent”.

  6. Be rational
    Lastly, and most importanly, you have to be rational. Avoid (or at least acknowledge) logical fallacies, call spades spades, and admit weaknesses where you believe them to be. Don’t speak as if you are the end-all, be-all authority. Computing is ridiculously varied, and your solution might not work for others for a wide variety of legitimate reasons. Your mileage will always vary. Don’t be whiny. I read many posts about linux, and sometimes all I can hear is Luke Skywalker whining “But I was going into Tosche Station to pick up some power converters…”. It doesn’t matter if its unfair, it doesn’t matter if its right, it doesn’t matter if its monopolist, don’t whine. Open source is going to take over the world, but not because M$ sux0rs or the mafiaa doesn’t want you to watch DVDs.

Advocates, next time you want to rant about Microsoft doing something bad for humanity, take some time and additionally post how you solve a day-to-day problem. Open source and linux will win because they will be the path of least resistance, and as advocates, it’s our job to make sure the path of least resistence is well-lit.

Comments (5)

Restart a windows service remotely

I've been working with Shibboleth, an Internet2 project to ease authentication and authorization across institutions. So far, its a mess of XML files, and its been a lot of guess and check on various magic strings. One annoyance in working with it was that I'd update the config files, and then need to remote into the server to restart the windows service using those files. Shibboleth will reread some of the config, but not all, so to be safe I just restart it.

After making a nant task to publish the latest config files for me, the need to click around to restart got very annoying. I wanted to get a way to restart it from the command line so I could restart it from my nant task. After a little googling and some futzing, I got it.

The solution

The program to use is sc.exe, a Service Controller. Unlike net.exe, sc lets you specify a server, so you can do things remotely.

Find the service name

You'll need the exact service name, which is stored in the registry. An easy way to find it is to enumerate all the services on the box, and then usually you can pick it out from there.

$ sc.exe \\\\server query | less

That will be a long list, so pipe it to less and page through it. That will list an entry for each service, like so:

SERVICE_NAME: shibd_Default
DISPLAY_NAME: Shibboleth 1.3 Daemon (Default)
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

This lets me know the service name I want to be using is "shibd_Default".

Stopping the service

Stopping is another simple command:

$ sc.exe \\\\server stop shibd_Default

SERVICE_NAME: shibd_Default
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 3  STOP_PENDING
                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x2
        WAIT_HINT          : 0x0
$

Note that is doesn't wait to stop the service, it merely makes a request to stop, then prints out the current status. The status is predicably STOP_PENDING. It's important to note that sc.exe doesn't wait for the service to stop, and that the request to stop may fail.

Starting the service

Starting is another easy command:

$ sc.exe \\\\server start shibd_Default

SERVICE_NAME: shibd_Default
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x1
        WAIT_HINT          : 0xbb8
        PID                : 2628
        FLAGS              :

This also only puts in the request for the service to start. As with stop, this request may fail.

Restarting using nant

To put it all together in nant, here's the plan:

  1. Send the stop request
  2. Sleep a little bit, to give the service a chance to stop
  3. Send the start request
  4. Sleep a little bit, to give the service a chance to start
  5. Send a query request, to check that it started ok

Here's a simplistic snippet of Nant xml for this:

XML:
  1. <!-- Send the stop request -->
  2. <exec program="sc.exe">
  3.   <arg line="\\server stop shibd_Default"/>
  4. </exec>
  5. <!-- Sleep a little bit, to give the service a chance to stop -->
  6. <sleep seconds="5"/>
  7. <!-- Send the start request -->
  8. <exec program="sc.exe">
  9.   <arg line="\\server start shibd_Default"/>
  10. </exec>
  11. <!-- Sleep a little bit, to give the service a chance to start -->
  12. <sleep seconds="5"/>
  13. <!-- Send a query request, to check that it started ok -->
  14. <exec program="sc.exe">
  15.   <arg line="\\server query shibd_Default"/>
  16. </exec>

The sleep time of 5 seconds probably needs to be adjusted for different services.

Conclusion

For once I'm not horribly disappointed in the tools microsoft has provided me. It would be nice if there was a "restart" command, or if you could tell sc.exe to wait until the service actually started or stopped, but there's at least something workable. Possible improvements would be to make this poll using sc \\server query shibd_Default to check for when the service actually stops or starts, I imagine 5 seconds isn't a universal upper bound.

If I get ambitious I might package up a nant task wrapping sc and send it to nantcontrib.

Comments (4)