Skip to main content

Posts

Showing posts from 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.

Method for finding disk space faster than du.

Mount all of the areas with your data with unique paths. E.g., /mnt/fileserver1/mystuff, /mnt/fileserver2/mystuff, etc. With cron, do periodic 'find -ls' runs to a file across all of you personal paths. 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

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 i

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