Skip to main content

Posts

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

HTML Grapher in Bash- A bash (awk et al) script for graphing two columns to HTML/CSS

#!/bin/sh # # * Copyright (c) 2008 # * Adam Keck. All rights reserved. # * # * Redistribution and use in source and binary forms, with or without # * modification, are permitted provided that the following conditions # * are met: # * 1. Redistributions of source code must retain the above copyright # * notice, this list of conditions and the following disclaimer. # * 2. Redistributions in binary form must reproduce the above copyright # * notice, this list of conditions and the following disclaimer in the # * documentation and/or other materials provided with the distribution. # * 3. The name Adam Keck may not be used to endorse or promote products derived from this software # * without specific prior written permission. # * # * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # * ARE DIS...

Systems Administration Koans [2008]

Some koans... ----------- A sysadmin asked the Master, "What's the best way to install a new system?" The Master answered, "Turn it on." The sysadmin was enlightened. ----------- A sysadmin asked the Master, "What's the root password to this server?" The Master asked, "Do you have access to the console?" The sysadmin replied, "Yes." The Master replied, "The root password is whatever you want it to be." The sysadmin was enlightened. ----------- An sysadmin seeks approval from the Master: "Master, I have designed and implemented a system with no single points of failure!" The Master answered, "Have you documented it?" "Not yet - I wanted to get it done first." The Master asked, "Give me the name of a team member that can build another one without seeing you or contacting you." "Well, I can't, yet - I just built it." The ...