System

My .bashrc and .emacs Configs

July 18, 2011

At the request of some of my buddies, I’m making a short blog post here to share my emacs configuration file as well as my bashrc file.  I don’t think there is a whole lot going on in either of these, but there are some nice tricks I’ve picked up over the years.  The links to download will get updated over time.  To start off with, we’ll go over my bashrc since it is the simpler of the two.

Bash RC

Grab my .bashrc file and I’ll go over some of the special features.  It starts off by dot sourcing in any other system wide bash configuration files (including the excellent bash_completion config).  It then creates a PATH variable that most notably includes the current directory so you can just execute blah.py instead of ./blah.py.  I then define my editor as emacs, increase my history file and require it to only store unique entries (instead of like 4000 cd ~/ commands for example). It then defines all the basic terminal colors to help make building and changing my prompt easier (stuff like production = PURPLE, development = RED, etc).  After that I set my terminal title bar (thanks to Nick), enable grep color if possible, add some alias commands for ssh and common switches, and export my uber prompt.  My prompt is really kind of nice due to it dropping input down a line and starting with a hash symbol.  This results in very nice scriptable copy and paste commands like:

image

Where the blue line down is just a paste of the previous commands.  The # and newline make the prompt a bash comment and what you enter a command.

After that cool prompt I just have a neat function I grabbed somewhere (and add to from time to time), that will extract pretty much any archive file I have without me having to remember the switches to pull out a gzipped tarball vs. a bz2.  It is always just: extract file_name

Emacs

My emacs config is slightly more complex since it includes some handy libraries.  To install it, you will need to copy the file emacs to your ~/.emacs and create a ~/.emacs.d folder.  Copy the vendor folder into ~/.emacs.d/.  That should be all you need (of course back up your existing config if you don’t want it overwritten.  In general this nice config moves all your blah.blh~ files to ~/.emacs.d/backups (which makes for a nice central backup of previous versions), as well as your #filename# files to ~/.emacs.d/saves.  It changes the default tab width to 4, gets rid of the welcome screen, gets rid of silly bells, and fixes tramp and other shells to handle the cool shell prompt defined above.

On top of that it adds a vbscript and powershell mode to the editor (for you Windows shell scripters), loads the lovely color-theme library and chooses a default theme, adds goto line (M-g), and adds a few handy commands like line wrapping and indenting entire buffers.

Hit me up with comments or send me an e-mail if you run into any snags or have suggestions for other neat bash and emacs configuration tricks.

tags : IT, System

Setting Up IPv6 on a Home Network with Linux

June 19, 2011

So I have an IPv6 class tomorrow so I decided to study by dinking around with setting up IPv6 on my home network. I was disappointed to find out that Ubuntu (even the current revision), still doesn't ship with ISC's DHCPD v4 server, so I couldn't with DHCPv6, but other than that it was a blast.

Install FUPPES for Streaming Media to XBox 360 and iPhone

January 17, 2011

On Saturday I went on a treasure hunt for a UPnP / DLNA server that would work with Deena’s iPhone, the XBox 360, and my Nokia N900.  I wanted to be able to get our large music collection to every device in the house without any fuss, and I figured out how to do that with FUPPES.  Here is a copy and paste style install guide for getting everything setup and running using Ubuntu Linux as the media server (FUPPES supports other operating systems as well).

Remote Backup of Files, Subversion, and MySQL Using Rsync and Ssh

June 13, 2010

TuxRecently my VPS provider was doing some power maintenance and recommended backing up data.  I realized I hadn't made a backup of that system in very long time, and hadn't worked up a backup strategy.  This caused me to whip up a backup solution using my two favorite things; ssh and rsync.

In the past I had used tar and scp to do remote backups, but this painfully slow, and I don't have a requirement to do moment in time backups, so the amazing efficiency of rsync.  The only trick was that this server has subversion and MySQL databases, and doing a straight copy of the data for these apps is extremely dangerous.  So with a couple remote ssh commands run from the backup machine I ended up with a slick, simple, fast, and reliable backup script:

#!/bin/bash

# Individually backup relevant etc configurations using rsync
# with the archive and compressions flags set
rsync -az -e "ssh -i path/to/ssh/key" backup_user@example.org:/etc/apache2 /data/backup/etc/
.
.
rsync -az -e "ssh -i path/to/ssh/key" backup_user@example.org:/etc/ssl /data/backup/etc/

# Use remote commands to trigger app specific backups for MySQL and subversion

# Run safe backup of all MySQL databases to a location that gets rsynced later
ssh -i path/to/ssh/key backup_user@example.org "mysqldump -u root -pPassword --all-databases > /opt/backup/mysql-current.sql"

# Run safe backup of subversion using svnadmin dump to a directory that gets rsynced
ssh -i path/to/ssh/key backup_user@example.org "svnadmin dump --quiet /opt/repos/svn > /opt/backup/svn.current.dump"

# Sync /opt.  Backup everything.  This will grab the remote MySQL and subversion backups
# we just made.
rsync -az -e "ssh -i path/to/ssh/key" backup_user@cexample.org:/opt/ /data/backup/opt/

That is it. I get a safe backup of my databases and svn plus all of my file data ~8 GiB total, and after the initial backup it all happens in less than 5 minutes.

Attach it all to crontab like:

0 * * * * /usr/local/bin/backup.py

and you get an hourly synchronized copy of the remote server.

 

tags : FOSS, IT, System, VPS

Another fun thing about Apache

January 30, 2010

So recently I have run into some fun to do with the apache Web server, and I thought it was worth sharing.  Well I didn't really, but my buddy Jeff did.  Just about every time there is a holiday over the weekend at my work, at some point the Web server would run out of memory so badly it would crash.  It would crash so hard in fact, that it had to be hard power cycled.  I have tried just about everything short of sacrificing a chicken to try and figure this out.  Everything from cron jobs to bad PHP scripts (not mine of course ), but never really figured out the root cause.  Of course that was until MLK Jr. Weekend.

tags : IT, System, Web

Apache Virtual Named Hosts and mod_gnutls

September 20, 2009

I have been waiting years for something like mod_gnutls to show up.  Finally I can use named hosts with SSL/TLS.  I just setup a new VPS and needed to setup three sites with SSL.  The problem is that I only have two IP addresses and an additional one would cost $1.50/month.  I was going to be happy with paying that extra money to have secured Web communication for authentication purposes, but I'm a cheap skate.

tags : IT, Security, System, Web

LTSP PXE Thin Clients

April 27, 2009

One of the projects I've worked on at the University of Kansas, School of Engineering is the PiXiE thin client project. This project started as brainstorm for creating high performance machines that provide limited but critical functions for engineering students. As a university we have constant budget problems and a difficult time coming up with enough money to maintain current computer hardware. This problem is compounded by the fact that engineers use a lot of high end memory, graphics and processor intensive software for modeling designs. Add to this that most of our students have better computers than we can offer due to budget constraints and typically only use our computer labs for free printing and Web access at school and we have the PiXiE projects.

tags : FOSS, IT, System

Samba With Windows Server 2008 Active Directory

April 27, 2008

Sun, April 27 2008

I spent a great deal of time yesterday messing with Samba and Windows Server 2008. I thought it would just be my normal messing around, but at some point by broken brain decided it was REALLY important to get linux connected to Windows Server 2008's Active Directory. Unfortunately, the currently released version of Samba 3.0.28a does not allow joing a linux computer to an Active Directory hosted on Windows 2008. But on the samba mailing list there was mentioning that on the test branch that they had fixed.