bash

Upstart Notes

Wednesday, January 26th, 2011 | bash, code, nerdery, tips, ubuntu | No Comments

I think I’m going to try to keep my notes about Upstart here in the hopes that it may save some others time in the future.

Where scripts should live:

/etc/init

Failed to connect to socket:

status: Unable to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Run commands as root (duhh):
sudo [start|stop|restart] SERVICE

Information regarding all the stanzas:

http://upstart.ubuntu.com/wiki/Stanzas

Tags: , ,

curl-ca-bundle Macports Checksum Woes

Tuesday, April 13th, 2010 | bash, code, hacks, nerdery | 5 Comments

Just got done pulling my hair out over some pretty stupid MacPorts problems, but eventually got things working again, so I figured I would share. My problem started with trying to upgrade curl to support SSL so that I could do git over http yadda yadda yadda. Little did I know that I could have just upgraded curl in the first place, but this serves to address another point. I’ll spare all the lame details, but in essence I got to a point where I was trying to re-install git-core but curl-ca-bundle, a dependency, was failing with this:

$ sudo port install curl-ca-bundle
---> Computing dependencies for curl-ca-bundle
---> Verifying checksum(s) for curl-ca-bundle
Error: Checksum (md5) mismatch for certdata-1.58.txt
Error: Checksum (sha1) mismatch for certdata-1.58.txt
Error: Checksum (rmd160) mismatch for certdata-1.58.txt
Error: Target org.macports.checksum returned: Unable to verify file checksums
Error: Status 1 encountered during processing.
Before reporting a bug, first run the command again with the -d flag to get complete output.

After some googling around, I found the bug and saw that it had been fixed. Great, the fix is only available in trunk. Ok so I’m thinking, I’ll just pull down trunk a build and run it. Why not I like to live dangerously:

Installing MacPorts from Subversion

Nope, that didn’t work either:

$ sudo ./configure --enable-readline
...
checking for existence of /usr/lib/tclConfig.sh... loading
checking for Tcl public headers... /usr/include
checking for tclsh... /opt/local/bin//tclsh
checking for Tcl package directory... /opt/local/lib/tcl8.5
checking whether tclsh was compiled with threads... no
configure: error: tcl wasn't compiled with threads enabled

Not really getting anywhere now am I. Dammit. But after scratching my head for a few minutes, I said, wait… this is all over a few lousy checksums? C’mon…So, in looking at the actual commit from the bug, I saw that it was just an updated Portfile and lightbulbs went off. All I had to do was copy the updated Portfile to my ports tree and port should see the updated checksums:

# cd to curl-ca-bundle
cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/net/curl-ca-bundle

# backup Portfile just in case, even though it's totally jank
sudo cp Portfile{,.bak}

# replace Portfile with one from trunk
sudo cp /opt/mports/trunk/dports/net/curl-ca-bundle/Portfile .

# install package that depends on curl-ca-bundle, in my case, git-core
sudo port install git-core

Seems like if I can’t install git-core, a pretty common package, then a lot of people are probably having this same problem. Hope this helps, I was at a loss for quite a while.

Beer-thirty!

Tags: , , , , ,

Tab-Complete SSH Logins

Monday, April 5th, 2010 | bash, code, nerdery, tips | 6 Comments

A smart guy named Dave Hull (@davehull) shared this piece of bash magic with me a while back and I have relied on it ever since because it’s just that handy. It’s a bit of a stretch to say that typing out “ssh” every time is that annoying, but when you can tab-complete hostnames to login, pure bliss ensues. Ok, so to do this we just need one magical little bash script:

#!/bin/sh
ssh $(basename $0) $*

I usually name this “ssh-to”. Doesn’t really matter though. What matters is how you link it up. But first, make sure this is somewhere in your PATH, like ~/bin and also make sure it’s executable:

mv ssh-to ~/bin
chmod +x ~/bin/ssh-to

Last step is just symlinking to a hostname:

cd ~/bin
ln -s ssh-to some.host.com

And that’s it. You should be able to type “some.<tab>” and the hostname will be tab-completed. Super handy if you’re like me and login to the same hosts frequently.

Tags: , , ,