Sunday, December 13, 2009

How to share files from Linux to Mac OS X with NFS

1. Install the NFS server packages on your Linux machine
2. Place the following in you /etc/exports
/path/to/share/    ip.of.nfs.client(rw,sync,insecure)
For example:
/home/user/     192.168.1.15(rw,sync,insecure)
Note the "insecure".
3. Restart your NFS services on the Linux machine
4. On Mac OS X type Command-K in Finder.
5. Type in nfs://ip.of.nfs.server/path/to/share/. For example:
nfs://192.168.1.15/home/user/
6. Click connect.
You should get a Finder window into the NFS share.

Things to consider if the connection fails:

Is your server running a firewall? If so, have you allowed NFS? If your server is running a firewall and does not need to (e.g. it and the client are in a trusted network), you may want to turn it off.

Do you have the correct IP address in /etc/exports on the Linux server? This is the IP address of the Mac OS X machine. Note that you can use the hostname as well if you have DNS set up or are using hosts files.

Friday, October 16, 2009

HTML grapher 2: Inline HTML grapher written in bash

New in this version:

o Cleaned up the code a bit. It's still a bit of a mess, though...
o Added scaling to graphs
o Only outputs the graph div, so it can be called by something else making the rest of the webpage.

Note: the code to html converter zaps the indenting. You may want to pass it through a pretty printer.

Tuesday, June 9, 2009

Method for finding disk space faster than du.


  1. Mount all of the areas with your data with unique paths. E.g., /mnt/fileserver1/mystuff, /mnt/fileserver2/mystuff, etc.

  2. With cron, do periodic 'find -ls' runs to a file across all of you personal paths.

  3. To count a certain directory:

cat find_ls_file | awk ' /^some\/sub\/path/ {sum += $7} END  { gb=(sum/1024/1024/1024); printf"%0.2f GB\n",gb}'

where find_ls_file holds the results of your find.  Even more useful is adding up any pattern, e.g., all .xvid files.
cat find_ls_file | awk ' /\.xvid/ {sum += $7} END  { gb=(sum/1024/1024/1024); printf"%0.2f GB\n",gb}'

Also, be sure to exclude snapshot directories from your find, if you have them (e.g., NetApp, ZFS)

Another advantage of this method is parallelism. You can farm out the finds if you need to.

Cheers,

Adam

Who am I?

I am an Senior DevOps Engineer.

I have a B.S. in Applied Mathematics and am a member of Alpha Sigma Lambda.

Outside of work, I study art, illustration, design, science, personal finance engineering, and the math of processes.

Cheers,

-Adam

Wednesday, May 20, 2009

Cupsd crash on Debian 5 (and certain Ubuntu versions)

We found an interesting issue today: Cups crashes once per week or more frequently with libc error 4.

We had a duplicate printers.conf entry. If printers.conf has a duplicate entry, cupsd cannot handle a HUP. It crashes. You can test this by duplicating a printer stanza and then either running /etc/init.d/cups force-reload or sending a HUP to the cupsd process.

Cheers

Wednesday, April 15, 2009

Convert lpd printcap to CUPS printers.conf - Rough draft.

It's perl, rather than bash. Some things need a bit more oomph.


#!/usr/local/bin/perl -w 
use strict;

my $Printcap = "/hub/share/etc/printcap";

my($a,$b,@Server,$c,@PrintQueue,);
my $i = 0;
my $j = 0;
open (PRINTCAP, "$Printcap") or die "can't open input file";

#Run through the printcap recording the queue and the server in separate arrays.  The separate arrays allow us to recall the data
#later asynchronously.  This looks like it could have been accomplished with a associative array, but there is no unique index, 
#since two print queues on separate servers can have the same name as far as I know - Adam 

while () {
 if ( /^\n$/ ) {
  $i++;
  }
 if ( /:lp\=:/ ) {
  ($a,$b,$Server[$i]) = split(/=/,$_);
  chomp $Server[$i];
  $Server[$i] =~ s/(\:|\\)//g;
  }
 if ( /:rp\=/ ) {
  ($c, $PrintQueue[$i]) = split(/=/,$_);
  $PrintQueue[$i] =~  s/(\:|\\)//g;
  chomp $PrintQueue[$i];
  }
}
# printcap ends on a new line so there will be no elements in the arrays for the last value of $i

$i--;

# Now having collected the data from printcap we dump the stanza for printers.conf
while ( $j <= $i ){
 print "\n";
 print "Info\n";
 print "Location\n";
 print "DeviceURI lpd://$Server[$j].my.company.internal.domain.com/$PrintQueue[$j]\n";
 print "State Idle\n";
 print "Accepting Yes\n";
 print "JobSheets none none\n";
 print "QuotaPeriod 0\n";
 print "PageLimit 0\n";
 print "KLimit 0\n";
 print "\n";
 $j++;
}


-Adam

Friday, January 23, 2009

Script to convert MAC Address to format used by PXELinux

This script takes CCCC.CCCC.CCCC or CC:CC:CC:CC or cc:cc:cc:cc and spits out

01-cc-cc-cc-cc for a PXELinux MAC address file on the "first network segment."

#!/bin/sh
# Name: pxemac
# Usage: pxemac ${MAC Address}

OS=`uname -s`

type () {

  TYPE=`echo $1 | sed s/[A-Za-z0-9]*//g`
  if [ "$TYPE" = ".." ]
  then
    return 0
  else
    return 1
  fi

}

linux () {

  if type $1
  then
    echo $1 | sed -e "s/\./-/g" -e "s/^/01-/" -e "s/-[A-Za-z0-9]\{2\}/&-/g" | tr A-Z a-z
  else
    echo $1 | sed -e "s/\:/-/g" -e "s/^/01-/" | tr A-Z a-z
  fi

}

nonlinux () {

  if type $1
  then
    echo $1 | sed -e "s/\./-/g" -e "s/^/01-/" -e "s/-[A-Za-z0-9]\{2\}/&-/g" | tr [A-Z] [a-z]
  else
    echo $1 | sed -e "s/\:/-/g" -e "s/^/01-/" | tr '[A-Z]' '[a-z]'
  fi

}

if [ "$OS" = "Linux" ]
then
  linux $1
else
  nonlinux $1
fi

Tuesday, January 20, 2009

New word from Todd Keck (industrial designer): Crapht

Crapht (crap + craft): Something constructed by an artisan that has high production values, but very little substance.

As in:

His code is really well commented and nicely structured, but if you look deeper, it's just crapht.

or

That new artist's latest show was advertised as art, but was mostly just crapht. (courtesy of Todd Keck)

(Goes with this site nicely :)

-ghostis