Archive for May, 2009

Energy Fuel Resource Mix

Friday, May 22nd, 2009

Last January, I mentioned my fuel resource mix from my power company in a blog post. Well, I've just received the percentages for 2008. They seem to be a full seven months ahead of schedule.

Source Percentage
Coal 55.0%
Gas 7.0%
Nuclear 34.8%
Oil 0.3%
Captured Methane Gas 0.3%
Geothermal 0.0%
Hydroelectric 0.9%
Solar 0.0%
Solid Waste 0.6%
Wind 0.9%
Wood or other Biomass 0.2%
Conventional Energy Subtotal 97.1%
Renewable Energy Subtotal 2.8%

Looks like a 0.08% improvement in the wind and nuclear category. Yes, I think nuclear is a good power source and shouldn't be overlooked. I have no problem with them using less coal though. I don't see the sequestering thing working out and would bother me to live on top of a crapload of poisonous gas trapped in the ground.

I also just found a spiffy spreadsheet of the resource mix over the last couple years on Delmarva's website.  Enjoy!

Configuring Linksys PAP2T for Asterisk

Friday, May 22nd, 2009

I recently bought a Linksys PAP2T to hopefully provide phone service for some family members. I didn't need to support the incoming phone line, so this device should be more than adequate. It seems to be a bit easier to configure as well. I just wanted to jot down some notes on what I did for future reference.

* Downloaded firmware updates from Cisco's website. The firmware on the device was very old. In order to update the firmware, the device needs to download it over tftp. I used their firmware updater tool within my Windows XP virtual machine.
* On the System tab, I configured the ntp servers to use 0.pool.ntp.org and 1.pool.ntp.org.
* On the Regional tab, I set the local date, time, and time zone. I also set the daylight savings time rule to "start=3/8/7/2:0:0;end=11/1/7/2:0:0;save=1" (without the quotes). Although this device may go where there isn't a daylight savings time change, so this will need to get revisited.
* On the Line 1 tab, I set the proxy and outbound proxy to my asterisk server hostname. I set "use outbound proxy" to yes as well as making sure "register" was set to yes. I set the display name (although I think it'll get overridden by options in my sip.conf). I set the user id and password to match what is in my sip.conf. I am also tempted to try different codecs to be used as the preferred one. Right now I've left it as the default (G711u). I also added "1xx" to the dial plan for my internal extensions.

That was it. I am also tempted to get to use the provisioning framework for updating the settings. Although once it's set, I don't plan on changing anything. The SPA-3102 has been working great for months.

Below is an example of the entry in my sip.conf file.

; Line1 on PAP2T
;
[999]
type=friend
host=dynamic
context=local
username=999
secret=supersecret
callerid="Pat Hennessy" <999>
nat=yes
canreinvite=no
dtmfmode=rfc2833
qualify=yes
mailbox=999@default

Linode Dynamic DNS Ash Script

Monday, May 11th, 2009

After my post last night regarding a bash script to update Linode's DNS Manager, opello from #linode on OFTC provided some sed commands to parse the JSON output. Using his commands, I made another version of the script.  I've tested this on my router running the Tomato firmware (which runs BusyBox).

I found that the wget command built into the version of BusyBox does not support HTTP POST. It also does not support https urls, only http. This means your Linode API key would be transmitted in clear text, which probably isn't a good thing.

Another solution that was suggested was to simply wget a CGI script running on your webserver, which could update the Linode DNS Manager using perl or python over secure channels. That would reduce the complexity on the home router side and allow you to use the developed Linode API libraries.

Therefor, I wouldn't recommend using this unless you are able to send the requests over ssl channels. I am glad to have a slightly better understanding of sed. I'll probably modify the original bash script to use that as well.

#!/bin/ash
#
# Script to update Linode's DNS Manager for a given name.
#

# Things you need to change.
APIKEY=$(cat /home/root/linode-apikey)
LASTIP="/tmp/lastip"
DOMAIN="domain.com"
SOAEMAIL="hostmaster@domain.com"
STATUS="1"
RRTYPE="A"
RRNAME="home"
IFACE="vlan1"

# Shouldn't need to change anything below here.

WGET="wget -qO - http://api.linode.com/api/?api_key=$APIKEY"
NEWIP=$(ifconfig $IFACE | head -n2 | tail -n1 | cut -d: -f2 | cut -d' ' -f1)
test -e $LASTIP && OLDIP=$(cat $LASTIP) || OLDIP=""

if [ x"$OLDIP" = x"$NEWIP" ]; then
  logger "No IP address change detected. Keeping $NEWIP"
else
   DOMAINID=$($WGET"&action=domainList" | 
        sed -nr "s#.*"DOMAIN":"$DOMAIN","DOMAINID":([0-9]+),.*#1#p")
   RESOURCEID=$($WGET"&action=domainResourceList&DomainID=$DOMAINID" | 
        sed -nr "s#.*"RESOURCEID":([0-9]+),"DOMAINID":$DOMAINID,"TYPE":"$RRTYPE","NAME":"$RRNAME".*#1#p")
   $WGET"&action=domainResourceSave&ResourceID=$RESOURCEID&DomainID=$DOMAINID&Name=$RRNAME&Type=$RRTYPE&Target=$NEWIP"; echo
   $WGET"&action=domainSave&DomainID=$DOMAINID&Domain=$DOMAIN&Type=master&Status=$STATUS&SOA_Email=$SOAEMAIL"; echo
   echo $NEWIP > $LASTIP
   logger "Updated IP address to $NEWIP"
fi

css.php