Pages

Wednesday, June 24, 2009

HOWTO: Set the SSHD Idle Timeout

Here's something that I usually forget to change from the default and then get annoyed when my terminal hangs.
  1. As root open your sshd_config file in an editor.
    su -  
    vim /etc/ssh/sshd_config  
    

  2. Add the following lines.
     ClientAliveInterval 600  
     ClientAliveCountMax 3

  3. Restart the sshd process.
     service sshd restart
That's it. That will keep you logged in for 30 minutes at a time without activity. (600 seconds x 3)

Saturday, April 4, 2009

M3U Playlist Copy Script

A couple of months ago I picked up a Garmin Nuvi 760 on the cheap. As it turns out this great GPS unit can also play music quite well, especially for riding on the motorcycle. The only problem was there was no good way to get playlists on the device that I could find. Enter the following bash script. This script will read an m3u file, copy all associated mp3 files, and generate a new m3u file. Now all I have to do is specifiy m3u files that I exported from Mozilla Songbird and the path to the Garmin's SD card.

 #!/bin/bash  
 # April 4, 2009  
 # m3u_cp.sh  
 #  
 # Take an m3u file and copy all associated mp3 files  
 # to a destination directory and generate a new m3u.  
 #  
 # Used to copy m3u playlists from computer to Garmin.  
 if [ $# -lt 2 ]; then  
 echo "Usage: m3u_cp.sh some.m3u /dst"  
 exit 0  
 fi  
 # Read the m3u file into an array  
 declare -a M3U  
 exec 10<"$1"  
 let count=0  
 while read LINE <&10; do  
 M3U[$count]=$LINE  
 ((count++))  
 done  
 exec 10>&-  
 # Determine the m3u's filename  
 if [[ $1 =~ [^/]*m3u ]]; then  
 m3u_path="$2/$BASH_REMATCH"  
 fi  
 # If playlist arleady exists, delete it  
 if [ -f "$m3u_path" ]; then  
 rm -f "$m3u_path"  
 fi  
 # Loop through the m3u lines  
 i=0  
 while [ $i -lt ${#M3U[@]} ]; do  
 # The current line is a comment, do nothing with it  
 if [ ${M3U[$i]:0:1} = "#" ]; then  
 echo ${M3U[$i]} >> "$m3u_path"  
 #Current line is a path to an mp3 file  
 else  
 # Get the current songs filename  
 if [[ ${M3U[$i]} =~ [^/]*mp3 ]]; then  
 song=$BASH_REMATCH  
 mpath=$( echo ${M3U[$i]} | tr -d '\r' )  
 # if the song doesn't exist, copy it to the desitnation folder  
 if [ -f "$2/$song" ]; then  
 echo File Exists -- $song  
 else  
 echo Copying -- $song  
 cp "$mpath" "$2/$song"  
 fi  
 # Write the song in the m3u file  
 echo $song >> "$m3u_path"  
 else  
 echo "The regex for finding the song's filename is fraked up."  
 fi  
 fi  
 let i=i+1  
 done  
 exit 0  

In the middle of writing this I really started wondering why I used bash. Perl would've been a lot easier.

Wednesday, March 11, 2009

SVN+SSH Howto: Subversion Quick and Simple

Here's a quick and simple way to create a Subversion repository while maintaining security by using SSH and the filesystem permissions.
  1. Create users and add them to a group. There are a bunch of different ways to do this. I am only showing you how to create a group.
    groupadd svn-users

  2. Make a directory to house the repository.
    mkdir /var/lib/project

  3. Create the repository.
    svnadmin create /var/lib/project

  4. Change permissions to allow the group read/write access.
    cd /var/lib/project
    chgrp svn-users db db/transactions db/write-lock db/revs db/revprops hooks locks
    chmod 2770 db db/transactions db/revs db/revprops
    chmod 660 db/write-lock
    chmod 750 hooks
    chmod 770 locks
You can now have your users access the repository over SSH.

svn+ssh://username@server.example.com/var/lib/project

If your clients are on Windows, I recommend using TortoiseSVN.

Credit goes to the Carnival of Technology.

Friday, June 27, 2008

HTTP to HTTPS Forwards Please

Why do some sites that require a secure connection not automatically forward you to the secure site? How hard is it to do? Not very! (with Apache at least)

 #How about a simple .htaccess file in the webroot?  
 #Force SSL for example.hwarf.com  
 RewriteEngine On  
 RewriteBase /  
 RewriteCond %{HTTPS} !=on  
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Hopefully some sites will pay attention to this. I'm not mentioning any URLs.

Friday, May 30, 2008

Time Warner Cable / Road Runner - The Rip Off

After 6 months with Time Warner Cable's Road Runner Internet service at home I was hit with a nice surprise. Month 7th would cost me $70.95, instead of the $44.95 that was/is advertised on their site. For some reason my location does not get their standard pricing. While my initial service was great, below I've identified some issues I have with Time Warner that has led me to cancel my account.
  • Their 800 Number - Whenever I try to call their customer support number I have to call at least five to ten times to get through. For some reason I keep getting a busy signal. Annoying!

  • Hold Times - It takes about 10-15 minutes to get someone on the phone. I really wish I would've bought a speakerphone.

  • Getting Bounced Around - During my first of three calls I was bounced around to three different operators that could not help me. However, before I reached the third person I was conveniently lost in phone-space and had to call back.

  • Lack of Logic - There was no good explanation as to why the Road Runner service costs so much more in my area than someone who lives a couple miles from me.

  • Customer Support Staff - While the staff was very nice, they were unable to help me. It was quite frustrating having someone tell me, "I agree that $70.95 is ridiculous and I have no idea why it is priced that way. I can understand why you would want to cancel."
As of next week I will no longer be a Road Runner customer and have since signed up with the Windstream Greenstreak service. The biggest disappointment about their DSL service is that they claim I only qualify for 3Mbps service. After living with 7Mbps and 15Mbps for the last year and a half, 3Mbps is going to feel pretty slow. I guess no more streaming HD movies from the iTunes store to the AppleTV.

Wednesday, February 27, 2008

Googlebot and FreeDNS from afraid.org

Back on January 8th I canceled my Dreamhost account and began hosting my site off of my cable modem. Only receiving ~15 hits a day I figured I might as well save myself $120 a year. So I chose freedns.afraid.org to host my DNS. They were free and had all the options that I wanted, including working with Tomato.

After the switch I noticed that my traffic had declined dramatically, down to ~1 hit per day. So I starting doing a bit of investigating and found that Google was no longer crawling my site and had deleted my previous results. Logging into the Google Webmaster Tools I found that Google was having DNS issues connecting to my site. Well, after pulling my hair out for an evening I found that FreeDNS was blocking the googlebot from crawling my site.

Solution: I have switched my DNS provider to ZoneEdit. ZoneEdit offers similar features to that of FreeDNS. Now Google can access my site again, but I'm no longer in the results for some searches. I guess it will take some time. Yahoo and Live search were totally unaffected by FreeDNS.

So this is a warning to all people using FreeDNS and want Google to crawl their site.

Thursday, February 21, 2008

Installing Netbackup Enterprise Server 6.5 on CentOS 5 / RHEL 5 withSELinux

It took me almost a whole day to come up with this solution. This should get Veritas Netbackup Enterprise Server 6.5 up and running on a CentOS 5 / RHEL 5 box with SELinux enabled.


HOWTO: Server

  1. Install a couple of dependencies:
    yum install compat-libstdc++-296 xinetd libXp 

  2. Make sure that the hostname is set correctly. This is very important.

  3. Temporarily disable SELinux:
    setenforce 0

  4. Untar the installation files:
    tar xvf NetBackup_6.5_LinuxRedhat2.6.tar.gz
    tar xvf NetBackup_6.5_ICS_LinuxX86.tar.gz

  5. Start the installation:
     ./NB_65_LinuxR_x86_20070723/install
    .....
    #ICS Directory: ./NB_65_ICS_1.4.37.0_LinuxX86/


  6. Fix SELinux:
    chcon -t textrel_shlib_t /usr/openv/lib/*
    setenforce 1


  7. Start Netbackup:
    /etc/init.d/netbackup start

HOWTO: Client

  1. Untar the installation file:
    tar xvf NetBackup_6.5_CLIENTS2.tar.gz

  2. Start the installation:
    NB_65_CLIENTS2_20070723/install

  3. Fix SELinux issues:
    chcon -t textrel_shlib_t /usr/openv/lib/*

  4. Start the client:
    /etc/init.d/nbclient start