Friday, February 15, 2008

Patterns of deployment

This link just flew across the transom, and since I'm think in automated deployment on most projects I'm on I thought it was too good not to pass on.

It's called "Patterns of deployment" and the best part I think is the info about host-specific / environment stuff. That's always a tough nut to crack

Windows locks files, I unlock them

Still dealing with a recalcitrant windows environment where I'm trying to automate the deployment of a ColdFusion application.

Problem is, even after you stop the ColdFusion servers (and you ensure they're down via tasklist.exe inspection), some files are still locked.

It appears the only way to unlock them is to reboot the machine. (yes, I know this is abhorrent, believe me, I'd avoid it)

The way to do this easiest (I think) is to use the 'sc' Windows builtin to set the services to start manually (instead of automatically) (e.g. 'sc config "" start= demand')


Then reboot the machine, and check remotely until the machine's uptime is recent (via something like 'net statistics srvr|grep since 2>&1') via ssh, then parsing (m/\D+(\d+)\D(\d+)\D(\d+)\s+(\d+):(\d+)\s+(AM|PM)/) out the uptime (using Time::Local, and being careful if you don't get what you expect since that machines the machine is rebooting so the connection failed).

Once it's rebooted, you should be good to go, then just sc to set the start back to "auto" and you're done.

Easy (ha)

cygwin messes up windows permissions, cacl fixes them

I recently had the misfortune to work in a windows environment via cygwin+openssh

This is a seemingly civilized configuration - to my unix-biased way of thinking - as cygwin gives me a shell and ssh is a very familiar way to access machines for logins and automation.

Unfortunately, Windows has a very complex permissions scheme (ACLs) and cygwin+openssh+scp just won't honor Windows permissions. No matter how I tried, the files would land on the server without properly inheriting the permissions of the directories they landed in.

Luckily, Windows provides a relatively easy way to fix this problem in the utility cacls.

What I ended up doing was using cacls with the '/S' switch to get the string representation of the parent directory of the location I copied files to, then used the '/S:' switch again, this time with the string I got from the first invocation, but now targeted at the actual directory I was working in.

You can use the nifty "AccessEnum" utility (google it) to verify your permissions a lot more quickly than a ton of right-click/sharing-tab examinations.

Poof, perfectly consistent permissions.

I'll continue choosing unix for my servers though, thank you...