<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>Tim Dysinger</title>
  <link href="http://dysinger.net/atom.xml" rel="self"/>
  <link href="http://dysinger.net/"/>
  <updated>2011-12-21T14:30:36-10:00</updated>
  <id>http://dysinger.net/</id>
  <author>
    <name>Tim Dysinger</name>
    
  </author>

  
  <entry>
    <title>Importing Enron into CouchDB</title>
    <link href="http://dysinger.net/2009/02/10/importing-enron-into-couchdb/"/>
    <updated>2009-02-10T06:02:44-10:00</updated>
    <id>http://dysinger.net/2009/02/10/importing-enron-into-couchdb</id>
    <content type="html">&lt;p&gt;I have been goofing around with couchdb for about a year now.  In
order to do anything fun or interesting with it, you first must have
some data to play with.  To solve this I imported the enron email
dataset into couchdb so we can have a couple hundred thousand
documents.&lt;/p&gt;

&lt;p&gt;How? First I downloaded all enron data from the Carnagie Melon
University&amp;#8217;s &lt;a href=&quot;http://www.cs.cmu.edu/~enron&quot;&gt;Enron Email Data&lt;/a&gt;.  Then I
used the &amp;#8216;mail trends&amp;#8217; project&amp;#8217;s enron.py code to convert the loose
files into a unix mbox format so it&amp;#8217;s easily understood by code. Once
we have the enron data in a format we like, we can use a ruby script
below to take the email and push it into couchdb.  (Make sure your
couchdb installed and running.)  The code is as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cat &amp;gt;;rakefile.rb &amp;lt;&amp;lt;\THEEND
%w(time tmail find restclient json).each {|l| require l}

file_create(&#8216;enron_mail_030204.tar.gz&#8217;) do
  `curl -O http://download.srv.cs.cmu.edu/~enron/enron_mail_030204.tar.gz`
end

file_create(&#8216;maildir&#8217; =&amp;gt; &#8216;enron_mail_030204.tar.gz&#8217;) do
  `tar xzof enron_mail_030204.tar.gz`
end

desc(&#8216;import the email to localhost couchdb&#8217;)
task(:import =&amp;gt; &#8216;maildir&#8217;) do
  RestClient.put(&#8216;http://localhost:5984/enron&#8217;, &#8221;) rescue nil
  Find.find(&#8216;maildir&#8217;) do |path|
    next if FileTest.directory?(path)
    begin
      txt = IO.read(path)
      msg = TMail::Mail.parse(txt)
      next if msg.date &amp;lt; @t = Time.parse(&quot;1999-01-01&quot;)
      attrs = msg.header.merge(&#8216;to&#8217; =&amp;gt; msg.to_addrs,
                               &#8216;cc&#8217; =&amp;gt; msg.cc_addrs,
                               &#8216;bcc&#8217; =&amp;gt; msg.bcc_addrs,
                               &#8216;body&#8217; =&amp;gt; msg.body).reject {k,v v.to_s.empty?}
      RestClient.post(&#8216;http://localhost:5984/enron&#8217;,
                      attrs.to_json,
                      :content_type =&amp;gt; &#8216;application/json&#8217;)
    rescue Interrupt
      exit(1)
    rescue Exception =&amp;gt; ex
      puts &quot;#{path} #{ex.inspect}&quot;
    end
  end
end
THEEND

sudo gem install rake rest-client json tmail
rake -T
rake import
# &#8230;..wait for it&#8230;..
rake irb
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will take a while. Not long after the script starts you will see
documents showing up in your couchdb.  You will see a couple dozen
emails are not properly formatted or that wont convert to json but
you&amp;#8217;ll still end up with most of the emails in your couchdb.  Navigate
to &lt;a href=&quot;http://localhost:5984/_utils&quot;&gt;Couchdb&amp;#8217;s Futon&lt;/a&gt; and start mappin&amp;#8217;
and reducin&amp;#8217; :)&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Using Amazon EC2 Metadata as a Simple DNS</title>
    <link href="http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns/"/>
    <updated>2008-10-13T11:42:25-10:00</updated>
    <id>http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns</id>
    <content type="html">&lt;p&gt;I use the amazon metadata for creating /etc/hosts and do this on a
cron schedule.  This does everything I need.  Instead of fancy DynDNS
tricks or having to run and manage an internal DNS server I just have
a ruby script that looks at the metadata ec2 to build /etc/hosts.
It&amp;#8217;s easy.  To set it up yourself and try it all you need are 3 easy
steps.&lt;/p&gt;

&lt;p&gt;Start each of your instances with unique named key that matches what
you want their internal hostname to be.  Such as &amp;#8220;onion&amp;#8221; or &amp;#8220;potato&amp;#8221;
or whatever you want to call them.&lt;/p&gt;

&lt;p&gt;Make sure you have ruby, rubygems and amazon-ec2 (rubygem) installed.
Then create a ruby script in /usr/local/sbin/hosts that has the
following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env ruby
%w(optparse rubygems EC2 resolv pp).each {|l| require l}
options = {}
parser = OptionParser.new do |p|
  p.banner = &quot;Usage: hosts [options]&quot;
  p.on(&quot;-a&quot;, &quot;&#8211;access-key USER&quot;, &quot;The user&#8217;s AWS access key ID.&quot;) do |aki|
    options[:access_key_id] = aki
  end
  p.on(&quot;-s&quot;,
       &quot;&#8211;secret-key PASSWORD&quot;,
       &quot;The user&#8217;s AWS secret access key.&quot;) do |sak|
    options[:secret_access_key] = sak
  end
  p.on_tail(&quot;-h&quot;, &quot;&#8211;help&quot;, &quot;Show this message&quot;) {
    puts(p)
    exit
  }
  p.parse!(ARGV) rescue puts(p)
end
if options.key?(:access_key_id) and options.key?(:secret_access_key)
  puts &quot;127.0.0.1 localhost&quot;
  EC2::Base.new(options).describe_instances.reservationSet.item.each do |r|
    r.instancesSet.item.each do |i|
      if i.instanceState.name =~ /running/
        puts(Resolv::DNS.new.getaddress(i.privateDnsName).to_s +
             &quot; #{i.keyName}.ec2 #{i.keyName}&quot;)
      end
    end
  end
else
  puts(parser)
  exit(1)
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Setup a cron job to update /etc/hosts as often as you like.  I do it
once per hour on all my machines&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;0 * * * * /usr/local/sbin/hosts -a myaccess -s mysecret &amp;gt;/etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;All my machines have this ec2 security key + script + cron approach.
I do not have to run dyndns or any private dns servers to keep track
of all my internal server ip addresses.  My /etc/hosts looks like the
following on the three machines in the test cluster:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;127.0.0.1 localhost
10.252.202.221 oahu.ec2 oahu
10.253.115.175 maui.ec2 maui
10.253.114.190 hawaii.ec2 hawaii
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Rack: An API for Web Servers and Ruby Frameworks</title>
    <link href="http://dysinger.net/2008/04/25/rack-an-api-for-web-servers-and-ruby-frameworks/"/>
    <updated>2008-04-25T14:11:58-10:00</updated>
    <id>http://dysinger.net/2008/04/25/rack-an-api-for-web-servers-and-ruby-frameworks</id>
    <content type="html">&lt;p&gt;In today&amp;#8217;s ruby web application landscape, every framework developer
is writing his/her own handlers for every server he/she wants to
support. This results in semi-duplicate code, if not for the
web-server developer then for the framework-developer. This is the
pain-point that &lt;a href=&quot;http://rack.rubyforge.org/&quot;&gt;Rack&lt;/a&gt; aims to solve. Rack
proposes &amp;#8220;why not have some common ground?&amp;#8221; Java did this with the
Servlet API 10 years ago. Python did this with WSGI 5 years ago.&lt;/p&gt;

&lt;p&gt;By leveraging Rack, framework developers and web-server developers
gain access to one another without having to write special
adapters. Today that&amp;#8217;s WEBrick, Mongrel, CGI, Ebb, Fuzed &amp;amp; Thin for
web-servers and Rails, Camping, Coset, Halcyon, Maveric, Merb,
Racktools::SimpleApplication, Ramaze, Sinatra &amp;amp; Vintage for
web-frameworks &lt;em&gt;(this list will undoubtably be outdated
soon)&lt;/em&gt;. Tomorrow every new web-server and web-framework that supports
Rack can be used together. You&amp;#8217;ll be able to pick and choose the best
web-server for you without changing your favorite web-framework and
vice-versa.&lt;/p&gt;

&lt;p&gt;&amp;#8220;What do Rails developers really stand to gain today by leveraging
Rack?&amp;#8221; It might be the ability to run several &amp;#8220;rackable&amp;#8221; applications
side by side inside a single web-server instance. It might be the
possibility to leverage or stack applications. You can intercept
requests, modify them and pass them through to other handlers. You can
also have multiple rackable applications sitting next to each other
that comprise one user-facing application. Don&amp;#8217;t like file uploads
with Rails? Use another web framework or the Rack API directly to
write it and place it along side your Rails app in the same
application. Want to use single-sign-on for 3 Rails apps? No
problem. Rack makes it easy to tie apps together.&lt;/p&gt;

&lt;h2&gt;Rack Hello World&lt;/h2&gt;

&lt;p&gt;( gem install rack &amp;amp; mongrel &amp;amp; first and then after firing up the
example visit &lt;a href=&quot;http://localhost:3000&quot;&gt;localhost&lt;/a&gt; )&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;%w(rubygems rack).each {|l| require l}
Rack::Handler::Mongrel.run(
  lambda {|x| [301, {&#8216;Location&#8217; =&amp;gt; &#8216;http://rubyurl.com/g6L&#8217;},&#8221;]},
  :Port =&amp;gt; 3000
)
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Karma Yoga in Software Engineering</title>
    <link href="http://dysinger.net/2008/04/22/karma-yoga-in-software-engineering/"/>
    <updated>2008-04-22T17:22:48-10:00</updated>
    <id>http://dysinger.net/2008/04/22/karma-yoga-in-software-engineering</id>
    <content type="html">&lt;p&gt;I work in software development and it is a very competitive
business. At times I have to catch myself, when I feel an emotion, and
ask myself &amp;#8220;Why?&amp;#8221;. Why am I being competitive? Why am I seeking
recognition? Why am I wanting control? Is my argument on the design
the best for the team? Are my motivations the best for the project?&lt;/p&gt;

&lt;p&gt;In reading about &lt;a href=&quot;http://en.wikipedia.org/wiki/Karma_Yoga&quot;&gt;Karma
Yoga&lt;/a&gt;, I realize that this is
exactly what software developers need to do when writing
software. Karma Yoga means &amp;#8220;discipline of action&amp;#8221; and is based on the
teachings of the Bhagwat Geeta, a sacred Sanskrit scripture of
Hinduism.&lt;/p&gt;

&lt;p&gt;Karma Yoga is described as a way of acting, thinking and willing by
which one does one&amp;#8217;s duty without consideration of personal selfish
desires, likes or dislikes. Acting without being attached to the
fruits of one&amp;#8217;s deeds. In software this is doing what needs to be done
for the betterment of the project and team without attaching your ego
and self-worth to the code you write or the contribution you make.&lt;/p&gt;

&lt;p&gt;When this mindset is taken on by software developers, collaboration,
camaraderie and team-work increases while tensions, egos, stress,
competition and caustic attitudes decrease. It has to be consciously
chosen, but this is something to be strived for on teams.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Creating Blank Git Branches</title>
    <link href="http://dysinger.net/2008/03/31/creating-blank-git-branches/"/>
    <updated>2008-03-31T16:43:29-10:00</updated>
    <id>http://dysinger.net/2008/03/31/creating-blank-git-branches</id>
    <content type="html">&lt;p&gt;Most of the time in git you will be creating branches of your main
project and working on them.  What if you wanted to create a git
headless branch called &amp;#8216;documentation&amp;#8217;?  It doesn&amp;#8217;t really deserve
it&amp;#8217;s own repository because it&amp;#8217;s so closely related.  The git project
itself does this with documentation.  The git project repository has
separate branches for master, docs and man pages etc too.  Here&amp;#8217;s how
you do it.&lt;/p&gt;

&lt;p&gt;Go into your git project and type&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git symbolic-ref HEAD refs/heads/empty
touch .gitignore
git add .gitignore
git commit -m &#8216;Initial headless branch commit&#8217;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s it - now you have a new branch &amp;#8216;empty&amp;#8217;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Creating the Perfect Gentoo Amazon EC2 AMI (image)</title>
    <link href="http://dysinger.net/2008/03/04/creating-the-perfect-gentoo-amazon-ec2-ami-image/"/>
    <updated>2008-03-04T07:40:09-10:00</updated>
    <id>http://dysinger.net/2008/03/04/creating-the-perfect-gentoo-amazon-ec2-ami-image</id>
    <content type="html">&lt;p&gt;&lt;em&gt;Update: I need to upgrade this for amazon ec2 2008-02-01 api.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I been playing with Gentoo again.  I hadn&amp;#8217;t been an active Gentoo user
since it pissed me off in a emerge -u world snafu in 2004.  I created
some Gentoo EC2 images and thought I would share with you all.&lt;/p&gt;

&lt;p&gt;I have recently stopped using Xen to create new images and started
using Amazon EC2 AMIs to create new AMIs directly &amp;#8211; &amp;#8220;dog food&amp;#8221;-style.
The script below is an example of this.  There is no need to have 32
&amp;amp; 64-bit Xen Dom0 machines around the house to get started
creating custom AMIs.  All you need is an Amazon EC2 account.  Just
fire up someone else&amp;#8217;s Linux image and go to work creating a new AMI.
I have been using Amazon&amp;#8217;s Fedora 4 &amp;#8220;developer&amp;#8221; 32-bit &amp;#8220;small&amp;#8221; image
to create a nice lean Gentoo image.  Here is my script.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Boot a developer image at EC2 &amp;amp;&amp;amp; Login as root on the instance

# Move the /tmp dir to the big drive
mv /tmp /mnt &amp;amp;&amp;amp; ln -sf /mnt/tmp /

# Bootstrap
mkdir /mnt/gentoo
wget -O - \
  http://gentoo.osuosl.org/releases/x86/current/stages/stage3-i686-2007.0.tar.bz2  \
  tar xjC /mnt/gentoo
wget -O - http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2  \
  tar xjC /mnt/gentoo/usr
wget -O - http://s3.amazonaws.com/ec2-downloads/linux-2.6.16-ec2.tgz  \
  tar xzC /mnt/gentoo/usr/src
zcat /proc/config &amp;gt;/mnt/gentoo/usr/src/linux-`uname -r`/.config

# FUSE module (has to be compiled with the same gcc as ec2&#8217;s kernel)
cd /tmp
wget -O - \
  http://superb-west.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.3.tar.gz  \
  tar xz
cd fuse-2.7.3
./configure &#8211;enable-kernel-module \
  &#8211;with-kernel=/mnt/gentoo/usr/src/linux-`uname -r`
cd kernel
make &amp;amp;&amp;amp; make install
mkdir -p /mnt/gentoo/lib/modules/`uname -r`
cp -r /lib/modules/`uname -r` /mnt/gentoo/lib/modules/`uname -r`

# Setup
cat /proc/mounts &amp;gt;/mnt/gentoo/etc/mtab
mount -o rbind /proc /mnt/gentoo/proc
mount -o rbind /dev /mnt/gentoo/dev
mount -o rbind /sys /mnt/gentoo/sys
cp /etc/resolv.conf /mnt/gentoo/etc

# Chroot
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1=&quot;(image) $PS1&quot;

# Modules / Kernel
depmod -a
modprobe loop
echo &#8216;loop&#8217; &amp;gt;&amp;gt;/etc/modules.autoload.d/kernel-2.6
echo &#8216;fuse&#8217; &amp;gt;&amp;gt;/etc/modules.autoload.d/kernel-2.6
cd /usr/src &amp;amp;&amp;amp; ln -sf linux-`uname -r` linux

# Cleanup
cd /
rm -rf tmp &amp;amp;&amp;amp; ln -sf var/tmp tmp
rm -rf opt &amp;amp;&amp;amp; ln -sf usr/local opt
rm -rf boot

# Root
usermod -p \
  `dd if=/dev/urandom count=50 2&amp;gt; /dev/null  md5sum  cut -d &quot; &quot; -f1-1` \
  root

# Rebuild
cat &amp;gt;/etc/make.conf &amp;lt;&amp;lt;\EOF
CFLAGS=&quot;-O2 -march=i686 -pipe -mno-tls-direct-seg-refs&quot;
CXXFLAGS=&quot;${CFLAGS}&quot;
CHOST=&quot;i686-pc-linux-gnu&quot;
MAKEOPTS=&quot;-j2&quot;
EOF
emerge &#8211;sync
emerge -e world
emerge &#8211;update &#8211;newuse &#8211;deep world ; # are these both needed ^ &amp;lt;-
etc-update
emerge eix gentoolkit
emerge &#8211;depclean
revdep-rebuild

# Locale
cat &amp;gt;/etc/locale.gen &amp;lt;&amp;lt;\EOF
en_US ISO-8859-1
en_US.UTF-8 UTF-8
EOF
locale-gen

# Timezone
cp /usr/share/zoneinfo/GMT /etc/localtime
cat &amp;gt;&amp;gt;/etc/conf.d/clock &amp;lt;&amp;lt;\EOF
TIMEZONE=&quot;GMT&quot;
EOF

# Mounts
cat &amp;gt;/etc/fstab &amp;lt;&amp;lt;\EOF
/dev/sda1 /        ext3  user_xattr          0 1
/dev/sda2 /mnt     ext3  user_xattr          0 2
/dev/sda3 swap     swap  sw                  0 0
shm       /dev/shm tmpfs nodev,nosuid,noexec 0 0
EOF

# TTY
perl -p -i -e &#8216;s/^c([^1])/\#c$1/g&#8217; /etc/inittab

# Network
emerge dhcpcd ddclient net-misc/ntp
rc-update add net.eth0 default
rc-update add sshd default
rc-update add ntpd default
cat &amp;gt;/etc/ssh/sshd_config &amp;lt;&amp;lt;\EOF
Protocol 2
StrictModes yes
MaxStartups 10:30:60
Ciphers aes256-cbc,aes256-ctr
PasswordAuthentication no
ChallengeResponseAuthentication no
Subsystem sftp /usr/lib/misc/sftp-server
UseDNS no
EOF

# Boot
cat &amp;gt;/etc/conf.d/local.start &amp;lt;&amp;lt;\EOF
# /etc/conf.d/local.start
# Root SSH Public Key
[ ! -e /root ] &amp;amp;&amp;amp; cp -r /etc/skel /root
wget &#8211;timeout 15 -q -O - \
  http://169.254.169.254/2007-12-15/meta-data/public-keys/0/openssh-key &amp;gt;\
  /root/.ssh/authorized_keys
chmod -R go-rwsx /root
# Userdata Shell Script
wget &#8211;timeout 15 -q -O - http://169.254.169.254/2007-12-15/user-data  sh
EOF

# EC2 tools
emerge ruby curl unzip symlinks
cd /tmp
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip
cd /usr/local
unzip /tmp/ec2-ami-tools.zip
ln -sf ec2* ec2-ami-tools
chmod -R go-rwsx ec2*
rm -rf /tmp/ec2*
# Recompile rsync (lutimes doesn&#8217;t work with old ec2 kernel)
cd /tmp
wget -O - http://www.samba.org/ftp/rsync/src/rsync-2.6.9.tar.gz \
  tar xz
cd rsync-2.6.9
perl -pi.bak -e &#8216;s/\blutimes\b//&#8217; ./configure
./configure &#8211;prefix=/usr/local/ec2-ami-tools
make
make install
cd ..
rm -rf rsync*

# Bundle
export AMAZON_USER_ID=&#8217;FIXME put your user id here&#8217;
export AMAZON_ACCESS_KEY_ID=&#8217;FIXME put your access key here&#8217;
export AMAZON_SECRET_ACCESS_KEY=&#8217;FIXME put your secret access key here&#8217;
cat &amp;gt;/mnt/pk.pem &amp;lt;&amp;lt;\EOF
&#8212;&#8211;BEGIN PRIVATE KEY&#8212;&#8211;
FIXME: put your cert here
&#8212;&#8211;END PRIVATE KEY&#8212;&#8211;
EOF
cat &amp;gt;/mnt/cert.pem &amp;lt;&amp;lt;\EOF
&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;
FIXME: put your cert here
&#8212;&#8211;END CERTIFICATE&#8212;&#8211;
EOF
export EC2_PRIVATE_KEY=/mnt/pk.pem
export EC2_CERT=/mnt/cert.pem

cat &amp;gt;/usr/local/sbin/image &amp;lt;&amp;lt;\EOF
#!/bin/bash
export EC2_AMITOOL_HOME=/usr/local/ec2-ami-tools
PATH=$EC2_AMITOOL_HOME/bin:$PATH
BUNDLE=`date &#8216;+%y%m%d%H%M%S&#8217;`
ec2-bundle-vol -r i386 -u $AMAZON_USER_ID \
  -k $EC2_PRIVATE_KEY -c $EC2_CERT \
  -b -d /mnt -s 10000 &#8211;fstab /etc/fstab \
  -e /root -p $BUNDLE
ec2-upload-bundle -b $HOSTNAME -m /mnt/$BUNDLE.manifest.xml \
  -a $AMAZON_ACCESS_KEY_ID -s $AMAZON_SECRET_ACCESS_KEY
rm -rf /mnt/$BUNDLE* /mnt/img-mnt
EOF
chmod 700 /usr/local/sbin/image

export HOSTNAME=gentoo-i686
rm -rf /var/tmp/* /usr/portage/distfiles /usr/portage/packages
symlinks -crsdv /
image

# Register &amp;amp; make the ami public (on another machine)
ec2-register $HOSTNAME/$BUNDLE.manifest.xml
ec2-modify-image-attribute ami-xxxxxx &#8211;launch-permission -a all

# Below is an example of a boot script that you might pass in as
# &quot;userdata&quot; You would configure the hostname and dyndns and/or
# maybe puppet or cfengine

#!/bin/bash
# Hostname
echo &#8216;HOSTNAME=&quot;fqdn.example.com&quot;&#8217; &amp;gt;/etc/conf.d/hostname
/etc/init.d/hostname restart
echo &#8216;127.0.0.1 &#8216;`hostname -f`&#8217; &#8216;`hostname -s`&#8217; localhost&#8217; &amp;gt;/etc/hosts
echo &#8216;search &#8216;`hostname -d` &amp;gt;/etc/resolv.conf
echo &#8216;nameserver 172.16.0.23&#8217; &amp;gt;&amp;gt;/etc/resolv.conf
echo &#8216;dhcp_eth0=&quot;release nodns nontp nonis&quot;&#8217; &amp;gt;/etc/conf.d/net
/etc/init.d/net.eth0 restart
# DynDNS
cat &amp;gt;/etc/ddclient/ddclient.conf &amp;lt;&amp;lt;\EOF
daemon=300
syslog=yes
mail=root
mail-failure=root
ssl=yes
use=web, web=169.254.169.254/2007-12-15/meta-data/public-ipv4
protocol=dyndns2, server=members.dyndns.org, custom=yes, \
login=FIXME, password=FIXME \
EOF
hostname &amp;gt;&amp;gt;/etc/ddclient/ddclient.conf
/etc/init.d/ddclient start
rc-update add ddclient default
fi

# After the new instance is booted, you may want to login and
# configure some basic tools or whatever

# Extras Tools
cat &amp;gt;&amp;gt;/etc/portage/package.keywords &amp;lt;&amp;lt;\EOF
dev-util/git
sys-fs/encfs
sys-fs/fuse
sys-fs/sshfs-fuse
EOF
emerge dev-util/git
emerge sys-fs/fuse sys-fs/encfs sys-fs/sshfs-fuse
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Using Ruby to Control Lego Mindstorms NXT</title>
    <link href="http://dysinger.net/2007/12/29/using-ruby-to-control-lego-mindstorms-nxt/"/>
    <updated>2007-12-29T08:38:28-10:00</updated>
    <id>http://dysinger.net/2007/12/29/using-ruby-to-control-lego-mindstorms-nxt</id>
    <content type="html">&lt;p&gt;Playing with my son on Lego NXT requires me to get Ruby in the mix
just for fun.  Here is the install notes that I used to get everything
going.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /tmp

# Ruby Serial
svn export http://ruby-serialport.rubyforge.org/svn/trunk ruby-serial
cd ruby-serial
ruby extconf.rb
make
sudo make install
cd ..

# Install libusb
svn export https://libusb.svn.sourceforge.net/svnroot/libusb/trunk/libusb libusb
cd libusb
sh autogen.sh
./configure
make
sudo make install
cd ..

# Ruby USB
svn export svn://svn@svn.a-k-r.org/akr/ruby-usb/trunk ruby-usb
cd ruby-usb
ruby extconf.rb
make
sudo make install
cd ..

# Ruby NXT
gem install ruby-nxt

# Try it in IRB
require &#8216;rubygems&#8217;
require &#8216;nxt_comm&#8217;
comm = NXTComm.new
comm.connected?
comm.get_device_info
comm.get_firmware_version
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Mounting Remote Servers as a Drive on OS X with Mac FUSE and SSHFS</title>
    <link href="http://dysinger.net/2007/12/15/mounting-remote-servers-as-a-drive-on-os-x-with-mac-fuse-and-sshfs/"/>
    <updated>2007-12-15T14:11:53-10:00</updated>
    <id>http://dysinger.net/2007/12/15/mounting-remote-servers-as-a-drive-on-os-x-with-mac-fuse-and-sshfs</id>
    <content type="html">&lt;p&gt;A handy tip for all you Mac OS X users out there: Have servers to deal
with over SSH?  You can download and install MacFUSE and SSHFS.  Once
you have installed both, you can fire up the SSHFS app.  SSHFS can
mount a remote server as a local drive on your mac.  Then you can edit
files in place and drag and drop files to transfer securely to the
remote server.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s pretty cool.  Thanks to the &lt;a href=&quot;http://fuse.sourceforge.net&quot;&gt;FUSE&lt;/a&gt;
team for writing it.  Thanks to Google for porting it to the Mac
&lt;a href=&quot;http://code.google.com/p/macfuse/&quot;&gt;MacFUSE&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Happy 60th Birthday, Dad!</title>
    <link href="http://dysinger.net/2007/12/02/happy-60th-birthday-dad/"/>
    <updated>2007-12-02T20:01:15-10:00</updated>
    <id>http://dysinger.net/2007/12/02/happy-60th-birthday-dad</id>
    <content type="html">&lt;p&gt;Just wanted to acknowledge my father as he turns 60 today.  I really
admire you and all of your accomplishments.  You have always taken the
time to talk with me and be a mad-scientist-mentor to me.  My first
gunpowder-bombs, tool-boxes, fishing-poles, camping-gear, snow-sleds,
mini-bikes, tree-forts, computers and other fun stuffs came from you,
dad.  Thanks for teaching me that moving forward requires persistence
and perspiration.  Thanks for encouraging me on my way with many a
computer-gift and a pat on the back for encouragement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I love you, dad.&lt;/strong&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Ruby Lasagna</title>
    <link href="http://dysinger.net/2007/10/20/ruby-lasagna/"/>
    <updated>2007-10-20T10:36:35-10:00</updated>
    <id>http://dysinger.net/2007/10/20/ruby-lasagna</id>
    <content type="html">&lt;p&gt;You have heard of
&lt;a href=&quot;http://en.wikipedia.org/wiki/Spaghetti_code&quot;&gt;Spaghetti&lt;/a&gt; code if
you&amp;#8217;ve done procedural or scripting-based programming.  A similar
thing can happen in Ruby with it&amp;#8217;s polymorphism and the super-dynamic
behavior.  Ruby can become a frustrating &amp;#8220;Lasagna&amp;#8221; sometimes with all
these dynamic classes, dynamic instances and dynamic behavior.  All
this can be hard to debug and follow.  It&amp;#8217;s almost like too many lisp
macros.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.chadfowler.com&quot;&gt;Chad Fowler&lt;/a&gt; recently wrote &lt;em&gt;&amp;#8220;I love the
tricks you can do with Ruby. method_missing, const_missing,
autoloading, and their friends make really powerful things possible.
But they do so at a price. When something goes wrong in a piece of
code that relies heavily on one of these tricks, it can be much much
harder to track down. So the decision to use such a tool shouldn’t be
taken lightly. These are power tools. Used effectively, really cool
things can happen. Used incorrectly, you can easily find yourself
limb-less and bloody. So when you decide to use one of these power
tools, you have to ask yourself: is it worth the risk?&amp;#8221;&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Try and Buy</title>
    <link href="http://dysinger.net/2007/10/16/try-and-buy/"/>
    <updated>2007-10-16T11:34:30-10:00</updated>
    <id>http://dysinger.net/2007/10/16/try-and-buy</id>
    <content type="html">&lt;p&gt;In working with my new hires, I have found the try-and-buy works
really well for the company.  50% of developers don&amp;#8217;t make it during
the trial period.  It&amp;#8217;s really important to try out new developers on
a paid trial for a while.  There is no interview long enough to make a
decision to hire.  Have them submit patches to your code base, don&amp;#8217;t
give them direct source access for the first week of the trial period.
Review their patches.  See how they respond to criticism.  Watch how
they interact with the team to solve problems.&lt;/p&gt;

&lt;p&gt;You may think 50%!?  That&amp;#8217;s high.  Not really.  Think about it: 80-90%
of all businesses fail in the first 5 years.  The start-up failure
rate is most likely higher on &amp;#8220;the internets.&amp;#8221; Just as much as it&amp;#8217;s
important to &lt;a href=&quot;http://onstartups.com/home/tabid/3339/bid/185/Startup-Hiring-Why-You-Should-Date-Before-Getting-Married.aspx&quot;&gt;try out your employees before you hire
them&lt;/a&gt;,
it&amp;#8217;s important for potential employees or consultants to try out
potential employers or clients before making any commitments.&lt;/p&gt;

&lt;p&gt;Lesson: You can&amp;#8217;t change people for the most part.  &amp;#8220;They are who they
are&amp;#8221; starts the day you meet them.  Pay close attention to warnings
and your gut.  If it&amp;#8217;s not a fit, let them go in the first 2 weeks.
Don&amp;#8217;t wait a month or a year.  Life is too short to work with
unqualified people.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Turn off your mac&#8217;s disk hibernation in OS X</title>
    <link href="http://dysinger.net/2007/09/07/turn-off-your-macs-disk-hibernation-in-os-x/"/>
    <updated>2007-09-07T09:52:50-10:00</updated>
    <id>http://dysinger.net/2007/09/07/turn-off-your-macs-disk-hibernation-in-os-x</id>
    <content type="html">&lt;p&gt;OS X has this deep-sleep mode that will save all the contents of Ram
to disk.  They do this just in-case you forget to charge it and the
battery drains.  However this causes a long hibernation time (the time
measure from the time you close the lid to the time you see the
&amp;#8220;breath&amp;#8221; light and it&amp;#8217;s safe to move the laptop).  During this long
hibernation time, you MUST NOT move or especially jerk the laptop
(like putting it in your bag).  If you do jerk you laptop around at
any time the hard disk is running, you can damage the hard disk.  It
is a moving-at-high-velocity part of your computer.&lt;/p&gt;

&lt;p&gt;If you are like me, there isn&amp;#8217;t but a few hours that go buy before I
am using my laptop again. The battery-draining-all-the-way situation
is almost never going to happen to me.  I am always backed up and
charged.  The laptop is my life-blood and my primary tool for my
income.&lt;/p&gt;

&lt;p&gt;So, rather than have the thing take for ever to sleep for a feature I
won&amp;#8217;t use, I decide to discover a way to turn it off.  The result is
the script.  Open a terminal and type the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo sh -c &quot;\
  pmset -a hibernatemode 0 ;\
  nvram use-nvramrc?=false ;\
  rm /var/vm/sleepimage &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 ;\
&quot;
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Sending email messages via SMS to mobile phones</title>
    <link href="http://dysinger.net/2007/08/30/sending-email-messages-via-sms-to-mobile-phones/"/>
    <updated>2007-08-30T09:16:23-10:00</updated>
    <id>http://dysinger.net/2007/08/30/sending-email-messages-via-sms-to-mobile-phones</id>
    <content type="html">&lt;p&gt;I find it incredibly simple and handy to send application alerts (and
sometimes friendly notes) via email to an SMS-enabled phone.  Most of
the big carriers have an email to SMS gateway.  Here are the email
addresses of the top 6 carriers.&lt;/p&gt;

&lt;h3&gt;T-Mobile&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@tmomail.net
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Virgin Mobile&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@vmobl.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;AT&amp;amp;T&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@mmode.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Sprint&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@messaging.sprintpcs.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Verizon&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@vtext.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Nextel&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;phonenumber@messaging.nextel.com
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Compiling Fuse kernel module for Debian 4.0 (Etch) on EC2</title>
    <link href="http://dysinger.net/2007/07/28/compiling-fuse-kernel-modules-for-debian-40-on-ec2/"/>
    <updated>2007-07-28T10:08:07-10:00</updated>
    <id>http://dysinger.net/2007/07/28/compiling-fuse-kernel-modules-for-debian-40-on-ec2</id>
    <content type="html">&lt;p&gt;I run Debian 4.0 (Etch) images at EC2 that I created on Xen and
bundled to EC2.  I discovered while trying to compile a kernel module
for &lt;a href=&quot;http://fuse.sourceforge.net/&quot;&gt;FUSE&lt;/a&gt; that Debian has
GCC 4.1 while all of EC2&amp;#8217;s kernels were built with GCC 4.0.  This is a
problem in that the kernel module, even though it compiles fine, will
not insert into the EC2 kernel.&lt;/p&gt;

&lt;p&gt;This was a bit of a road block for me as Debian Sarge has GCC 3.3/4
and Etch only has 4.1.  I had no access to 4.0.  Luckily Amazon
provides their stock Fedora images with developer tools.  I personally
hate RPM-based Linux distributions and Amazon&amp;#8217;s Fedora images are
broken and won&amp;#8217;t &amp;#8216;yum update&amp;#8217;.  However, Amazon&amp;#8217;s &amp;#8216;developer&amp;#8217; image at
least has GCC 4.0 on it along with the kernel source.  With that you
can compile a binary kernel module and tar it up for use elsewhere (on
your nice clean Debian images).&lt;/p&gt;

&lt;p&gt;Here are the steps I took to compile Fuse Kernel module on Amazon&amp;#8217;s
Developer Fedora image and move it to Debian 4.0.  Although this is
tailored for compiling the Fuse kernel module the same steps will work
for any other kernel module.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# DESKTOP: Fire up an EC2 fedora &quot;developer&quot; instance
ec2-run-instances -g sandbox -k sandbox ami-26b6534f

# DESKTOP: Login
ssh -i ~/.amazon/id_rsa-sandbox &#92;
  root@ec2-72-44-51-242.z-1.compute-1.amazonaws.com

# EC2: Remove old fuse
rpm -e `rpm -qa  grep fuse`

# EC2: Install FUSE module
cd /usr/local/src
curl -O http://superb-west.dl.sourceforge.net/sourceforge/fuse/fuse-2.6.5.tar.gz
tar xzf fuse-2.6.5.tar.gz
cd fuse-2.6.5
./configure &#8211;enable-kernel-module &#8211;with-kernel=/usr/src/linux-`uname -r`
cd kernel
make &amp;amp;&amp;amp; make install

# EC2: Package up the modules
tar -czf modules-`uname -r`.tgz /lib/modules/`uname -r`

# DESKTOP: Pull the modules off and stash them somewhere to use with your &#8216;real&#8217; linux distro
cd ~/Projects/sysadmin/files
scp -i ~/.amazon/id_rsa-sandbox
  root@ec2-72-44-51-242.z-1.compute-1.amazonaws.com:/modules-2.6.16-xenU.tgz .
svn commit . -m &#8216;Updated kernel modules for ec2&#8217;&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Migrating your virtual Debian 4.0 (Etch) from Xen to EC2</title>
    <link href="http://dysinger.net/2007/07/28/migrating-your-virtual-debian-server-from-xen-to-ec2/"/>
    <updated>2007-07-28T09:55:11-10:00</updated>
    <id>http://dysinger.net/2007/07/28/migrating-your-virtual-debian-server-from-xen-to-ec2</id>
    <content type="html">&lt;p&gt;If you have a linux server with Xen installed, you can develop and
test on Xen and migrate your images to EC2 easily when you are ready.&lt;/p&gt;

&lt;p&gt;First off you need to have Linux running in a Xen image.  This was
covered earlier in a post about installing Xen on Debian Hosts &amp;amp;
Guests &lt;a href=&quot;http://tim.dysinger.net/2007/06/14/xen-virtulization-with-debian-linux-4-its-easy/&quot;&gt;Xen Virtulization with Debian Linux 4 (It’s
easy)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have a running image on Xen, migrating to EC2 is fairly easy.
There are just a few steps that you need to follow.  I&amp;#8217;ve outlined
them below using Debian 4.0 as the distribution but you can choose
your own flavors.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# HOST: (Re)Install &amp;amp; Correct (for Debian) Amazon&#8217;s EC2 AMI tools &amp;amp; Ruby 1.8.6
sudo su -
apt-get install alien curl
curl -O http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
alien -i ec2-ami-tools.noarch.rpm
rm ec2-ami-tools.noarch.rpm
# IF YOU DO _NOT_ HAVE RUBY 1.8.6 installed from source
apt-get install ruby libopenssl-ruby1.8
ln -s /usr/lib/site_ruby/aes /usr/lib/ruby/1.8/
# IF YOU DO HAVE RUBY 1.8.6 installed from source
ln -s /usr/lib/site_ruby/aes /usr/local/lib/ruby/1.8/
# THEN
vi /usr/lib/site_ruby/aes/amiutil/image.rb
# exec( &#8216;for i in console null zero ; do /sbin/MAKEDEV -d &#8217; + dev_dir + &#8217; -x $
#       i ; done&#8217; )
# &#8230;&#8230;Should be&#8230;&#8230;
# exec(&quot;cd #{dev_dir} &amp;amp;&amp;amp; /sbin/MAKEDEV console &amp;amp;&amp;amp; /sbin/MAKEDEV std &amp;amp;&amp;amp; /sbin/MAKEDEV generic&quot;)
exit

# HOST: (Re)Install Amazon&#8217;s EC2 API tools
sudo apt-get install sun-java5-jre unzip
cd /usr/local
sudo rm -rf ec2*
sudo symlinks -crsd .
curl -O http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-api-tools.zip
rm ec2*/bin/*.cmd
chmod -R og-w ec2*
sudo chown -R debian:staff ec2*
rm ec2-api-tools.zip
ln -sf ec2-api-tools* ec2-api-tools
cd /usr/local/bin
ln -sf ../ec2-api-tools/bin/* .

# Download your ec2 certificate and put it in ~/.amazon/cert.pem
# Download your ec2 private key and put it in ~/.amazon/pk.pem
# Put your AWS Access key in ~/.amazon/access.txt
# Put your AWS Secret key in ~/.amazon/secret.txt
# Put your AWS Account # in ~/.amazon/user.txt
cat &amp;gt;&amp;gt; ~/.profile &amp;lt;&amp;lt; EOF
export JAVA_HOME=/usr
export EC2_HOME=/usr/local/ec2-api-tools
export EC2_PRIVATE_KEY=$HOME/.amazon/pk.pem
export EC2_CERT=$HOME/.amazon/cert.pem
export AMAZON_ACCESS_KEY_ID=`cat ~/.amazon/access.txt`
export AMAZON_SECRET_ACCESS_KEY=`cat ~/.amazon/secret.txt`
export PATH=$EC2_HOME/bin:$PATH
EOF
source ~/.profile
ec2-add-keypair sandbox # put key in ~/.amazon/id_rsa-sandbox
ec2-add-keypair development # put key in ~/.amazon/id_rsa-development
ec2-add-keypair test # put key in ~/.amazon/id_rsa-test
ec2-add-keypair production # put key in ~/.amazon/id_rsa-production
chomod -R go-rwsx ~/.amazon

#
# When are ready to deploy the image
#

# GUEST: Create an Amazon EC2 fstab
sudo su -
cd /etc
mv fstab fstab.xen
ln -sf fstab.xen fstab
cat &amp;gt; /etc/fstab.ec2 &amp;lt;&amp;lt; EOF
/dev/sda1 /     ext3  defaults             1 1
/dev/sda2 /mnt  ext3  defaults,user_xattr  1 2
/dev/sda3 swap  swap  defaults             0 0
none      /proc proc  defaults             0 0
none      /sys  sysfs defaults             0 0
EOF
exit

# GUEST: Install Amazon&#8217;s Linux Kernel modules on your image
sudo su -
cd /tmp
wget http://s3.amazonaws.com/ec2-downloads/modules-2.6.16-ec2.tgz
tar -xzf /tmp/files/modules-2.6.16-xenU.tgz
rm -rf /tmp/files
exit

# HOST: Stop the Xen image &amp;amp;&amp;amp; mount the disk &amp;amp;&amp;amp; switch to EC2 fstab
sudo xm shutdown image; # Wait for it to stop
sudo mount -t ext3 -o loop /xen/domains/image/disk.img /mnt
cd /mnt/etc
sudo ln -sf fstab.ec2 fstab
cd
sudo umount /mnt

#
# Setup EC2
#

# Add Groups
ec2-add-group sandbox  -d &#8216;Sandbox&#8217;
ec2-add-group website  -d &#8216;Website&#8217;
ec2-add-group database -d &#8216;Database&#8217;
ec2-add-group backend  -d &#8216;Backend&#8217;

# Open Ports
ec2-authorize sandbox -p 22
ec2-authorize website -p 80
ec2-authorize website -p 443
ec2-authorize default -p 54321

#
# Deploy to EC2
#

# Bundle Image
ec2-bundle-image -p image -i /xen/domains/image/disk.img
  -u `cat ~/.amazon/user.txt`

# Upload Image
ec2-upload-bundle -b ami.soniannetworks.com -m /tmp/image.manifest.xml
  -a `cat ~/.amazon/access.txt` -s `cat ~/.amazon/secret.txt`

# Register Image
ec2-register ami.soniannetworks.com/image.manifest.xml

# List Images
ec2-describe-images
ec2-describe-images -x all

# Run Image
ec2-run-instances -g sandbox -k sandbox ami-XXXXXXX

# List
ec2-describe-instances

# Login
ssh -i ~/.amazon/id_rsa-sandbox root@myhost.amazonaws.com

# Shutdown
ec2-terminate-instances i-XXXXXXX

# Unregister
ec2-deregister ami-XXXXXXX

#
# Post-Deploy Config @ EC2
#

# EC2: SSH in (as debian user)
ssh -p 54321 debian@my.host.at.ec2.amazonws.com
# EC2: Change password (as debian user)
# EC2: Reconfigure the new guests hostname
sudo su -
hostname myhost.ec2.mydomain.com
echo `hostname` &amp;gt; /etc/hostname
exit
# GUEST: Reconfigure mail (see xen.txt doc)
# GUEST: Configure services as needed (see xen.txt doc)

#
# Switching the Xen image back to work with Xen
#

# HOST: Mount the disk &amp;amp;&amp;amp; switch to Xen fstab &amp;amp;&amp;amp; start the Xen image again
sudo mount -t ext3 -o loop /xen/domains/image/disk.img /mnt
cd /mnt/etc
sudo ln -sf fstab.xen fstab
cd
sudo umount /mnt
sudo xm create /etc/xen/image.cfg
sudo xm console image
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Xen Virtulization with Debian Linux 4 (its easy)</title>
    <link href="http://dysinger.net/2007/06/14/xen-virtulization-with-debian-linux-4-its-easy/"/>
    <updated>2007-06-14T07:54:17-10:00</updated>
    <id>http://dysinger.net/2007/06/14/xen-virtulization-with-debian-linux-4-its-easy</id>
    <content type="html">&lt;p&gt;Install Debian 4 just like you normally would.  Choose a minimal
install with no tasksel features (No Desktop - No Standard).  Your
finished install OS from this point forward will be referred to as the
Host while virtual images will be referred to as Guests (below).  I&amp;#8217;m
just going to tear into the steps that follow a basic Debian 4
install.  They are as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Installing Debian 4 &amp;amp; Xen 3
#
# NOTE: if your HOST is on qemu add &#8216;-redir tcp:2222::22&#8217; to the parameters
#
# HOST  = The base Debian Xen install OS that&#8217;s hosts guests
# GUEST = The VMs you are within the Debian Xen HOST
#
# During install add a user called &#8216;debian&#8217; for non-root access
#

# HOST: Update
cat &amp;gt; /etc/apt/sources.list &amp;lt;&amp;lt; \EOF
deb http://debian.osuosl.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib non-free
EOF
apt-get update &amp;amp;&amp;amp; apt-get upgrade

# HOST: Tools
apt-get install pwgen deborphan symlinks less

# HOST: Mail
apt-get install exim4 mailx
echo root: tim@dysinger.net &amp;gt; /etc/aliases &amp;amp;&amp;amp; newaliases
dpkg-reconfigure exim4-config ; # Choose &quot;Internet Site&quot;
date  mail -s test root@localhost ; # should see email @ tim@dysinger.net

# HOST: SSH
apt-get install openssh-server
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
cat &amp;gt; /etc/ssh/sshd_config &amp;lt;&amp;lt; \EOF
Protocol 2
Port 54321
PermitRootLogin no
PasswordAuthentication no
UseDNS no
Subsystem sftp /usr/lib/openssh/sftp-server
EOF
rm /etc/ssh/*key*
dpkg-reconfigure openssh-server
# DESKTOP: Create SSH keys (if you don&#8217;t have them already)
ssh-keygen -t dsa ; # just [Return] at all prompts
# HOST: Then paste the content of the DESKTOP ~/.ssh/id_dsa.pub
# into HOST /home/debian/.ssh/authorized_keys
su - debian
mkdir ~/.ssh
cat &amp;gt;&amp;gt; ~/.ssh/authorized_keys &amp;lt;&amp;lt; \EOF
}}}
EOF
chmod -R go-rwsx ~/.ssh
exit
# DESKTOP: Try the ssh login before you trust everything&#8217;s OK
ssh -p 54321 debian@my.servers.host.name.com ; # should require no password

# HOST: Xen
apt-get install linux-image-2.6-xen-686 linux-headers-2.6-xen-686 \
xen-hypervisor-3.0.3-1-i386-pae xen-linux-system-2.6.18-4-xen-686 \
xen-ioemu-3.0.3-1 xen-tools libc6-xen bridge-utils
cat &amp;gt;&amp;gt; /etc/modules &amp;lt;&amp;lt; \EOF
loop max_loop=64
EOF
cat &amp;gt; /etc/xen-tools/xen-tools.conf &amp;lt;&amp;lt; \EOF
dir         = /xen
mirror      = http://ftp.us.debian.org/debian/
kernel      = /boot/vmlinuz-2.6.18-4-xen-686
initrd      = /boot/initrd.img-2.6.18-4-xen-686
debootstrap = 1
dist        = etch
image       = full
size        = 4Gb
memory      = 512Mb
swap        = 512Mb
dhcp        = 1
EOF
cat &amp;gt; /etc/xen/xend-config.sxp &amp;lt;&amp;lt; \EOF
(network-script network-bridge)
(network-script network-dummy)
(vif-script vif-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)
EOF
mkdir /xen

# HOST: Dhcp
apt-get install dhcp3-server
cat &amp;gt; /etc/dhcp3/dhcpd.conf &amp;lt;&amp;lt; \EOF
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.248;
option broadcast-address 66.199.242.207;
option routers 66.199.242.201;
option domain-name-servers 4.2.2.1, 72.29.96.250, 207.210.212.202;
option domain-name &quot;mysite.com&quot;;
subnet 66.199.242.200 netmask 255.255.255.248 {
  range 66.199.242.203 66.199.242.206;
}
host myserver {
  option host-name &quot;myserver.mysite.com&quot;;
  hardware ethernet 00:16:3E:18:CF:B3;
  fixed-address 66.199.242.206;
}
EOF

# HOST: Sudo
apt-get install sudo
visudo ; # make sure the bottom line has &#8216;debian  ALL=(ALL) ALL&#8217;

# HOST: Cleanup
reboot ; # after reboot - login as &#8216;debian&#8217; (NOT ROOT EVER AGAIN ON THIS HOST!)
sudo uname -r ; # running xen kernel ?
sudo dpkg &#8211;purge linux-image-2.6-686 linux-image-2.6.18-4-686

# HOST: Harden
# Read http://www.debian.org/doc/manuals/securing-debian-howto/
sudo apt-get install nmap
sudo nmap -p 1-65535 -T4 -sS `hostname` ; # have a look at your open ports
sudo apt-get install harden harden-clients harden-tools tiger chkrootkit lsof

# HOST: Firewall ( leave open eth0 port 54321 &amp;amp; add xenbr0 w/o NAT )
sudo apt-get install arno-iptables-firewall

# HOST: Guest
sudo xen-create-image &#8211;hostname image
sudo xm create /etc/xen/image.cfg
sudo xm list
sudo xm console image ; # Ctrl-] is exit

# GUEST: Prepare
passwd root ; # Change the password!!!
echo 127.0.0.1 localhost localhost.localdomian &amp;gt; /etc/hosts
adduser debian
usermod -G staff,src debian

# GUEST: Setup
#   1. Update (same as above)
#   2. Tools (same as above)
#   3. Mail (same as above)
#   4. Ssh (same as above)
#   5. Sudo (same as above)
#   6. Harden (same as above)
#   7. Firewall ( same as above but leave open eth0 ports 80 443 54321 )

# HOST: Cloning GUESTS

# HOST: Create a new Xen image (xen-create above)
# HOST: Copy the &#8216;image&#8217; disk to the clone
#   &#8216;image&#8217; must be shut down then
#     (cp /xen/domians/image/disk.img /xen/domains/mynewdomain/ )
# HOST: Boot your new xen guest (xm create above)
# GUEST: Change password (as debian user)
# GUEST: Reconfigure the new guests hostname
sudo su -
hostname dev.ec2.sonianarchive.com
echo `hostname` &amp;gt; /etc/hostname
exit
# GUEST: Reconfigure mail (above)
# GUEST: Configure services as needed (as debian user)
sudo invoke-rc.d nginx stop &amp;amp;&amp;amp; sudo update-rc.d -f nginx remove ; # example
sudo invoke-rc.d mongrel stop &amp;amp;&amp;amp; sudo update-rc.d -f mongrel remove ; # example
sudo invoke-rc.d mysql stop &amp;amp;&amp;amp; sudo update-rc.d -f mysql remove ; # example
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Mac OS X Postfix SMTP Mail Server Configuration</title>
    <link href="http://dysinger.net/2007/06/04/mac-os-x-postfix-smtp-mail-server-configuration/"/>
    <updated>2007-06-04T22:20:21-10:00</updated>
    <id>http://dysinger.net/2007/06/04/mac-os-x-postfix-smtp-mail-server-configuration</id>
    <content type="html">&lt;p&gt;I configured my macbook to accept all local mail and then forward it
to my personal email account.  This is super useful for testing your
local code that sends email.  You can send to any made up name like
herp@localhost or derp@my.machine.name and it will end up in your mail
box.  Here&amp;#8217;s the configuration changes I made.&lt;/p&gt;

&lt;p&gt;Add the following to the bottom of your /etc/postfix/main.cf:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;luser_relay = me@myemail.net
local_recipient_maps =
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Reload postfix &amp;amp; test :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo postfix reload
date | mail -s test lolkatz@localhost
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should have some mail delivery @ your me@myemail.net address.&lt;/p&gt;
</content>
  </entry>
  
</feed>

