Archive

Posts Tagged ‘camping’

DNS for bash

March 31st, 2008

Today, I decided I wanted a network service that propagated variables and aliases to every login shell that subscribed to it. This is dangerous on a large scale, but perfectly acceptable on my small home network where everyone trusts everyone else.

First, I got Camping installed, bringing back fond memories of Ruby development. I then copied off the blog example, and created TreeHugger, a 427 line script that provides a web interface to edit the variables, and a plain text output for the shells to source.

This script, when run, allows some simple MVC actions to an sqlite3 database.

Example Screenshot

As you can see, I have some aliases here I want to send to all the subscribing hosts. Eventually, I want to add some detection functionality to the database (mostly reverse DNS lookups for host rule referencing). I just have to access /out to get my desired output:


# Treehugger Configuration
# Aliases
alias ai='sudo apt-get install'
alias aup='sudo apt-get update'
alias aug='sudo apt-get upgrade'

# Environment Variables

Now, to get this into bash. I looked into making the date command spit out pretty unique timestamps. Turns out you can do this with the nanoseconds format:


$ date +%s%N
1206926780157462141

I made it so wget saves the treehugger config to a tempfile using the somewhat random seed above as a filename suffix, and then I have my shell source it:


FILENAME=/tmp/treehugger-`date +%s%N`; 2>/dev/null wget -O $FILENAME  http://rofl.who/treehugger/out && source $FILENAME && rm $FILENAME

And now I have nice aliases on my laptop served up from my desktop as fresh as the shell:


hank@davros:~$ alias
alias ai='sudo apt-get install'
alias aug='sudo apt-get upgrade'
alias aup='sudo apt-get update'
alias ls='ls --color=auto'


Uncategorized , , , , , , , ,

_why thinks I’m a bike

October 6th, 2006

I got featured on
Redhanded.
Apparently, I’m a bike. Probably because of my behavior under the name
o`o in IRC. Sigh, it’s my only claim to fame. :(


Uncategorized , ,

DNS Mania

September 2nd, 2006

Well, I was stumbling today and found OpenDNS. I
was excited to find that I could make it coexist with OpenNIC in my dhclient
configuration. Here’s the resultant line that makes all this magic happen:


prepend domain-name-servers 63.226.12.96, 208.67.222.222, 208.67.220.220;

So now, when I use dhcp to grab an IP, I end up prepending these nameservers
onto my resolv.conf. OpenDNS makes spam sites and domain squatters disappear.
And it makes the average request a lot faster.

Yesterday, bish0p and I sat down and started
work on MyDNS. It turns out that the db structure
isn’t all that bad, so it will be fairly straightforward to build a
Rails/Camping interface for it. I already started one in Camping called
Beacon. I was going to name it ChunkyBeacon, but #camping decided
against that.

In other news, I’m going to leave Fairbanks for a while soon. It will be
exciting to go on this adventure into the real world for four months.


Uncategorized , , , ,

Sanitizing Input in Camping

July 11th, 2006

So, I fixed up my RubySig Camping app today, and decided I should sanitize the input. Here’s how:


  require 'action_view'

    class Sig < R '/sig'
      include ActionView::Helpers::TextHelper
      def post
        ...
        ...

So, it was as simple as including the TextHelper in the Sig class. Including it inside post didnt work since that would be ludicrous. I thought about it a bit more, and figured it out. I love Ruby.

Uncategorized