« April 2008 | Main | June 2008 »

May 22, 2008

Quick script to back up a transcript

I was sick of writing lmerge /path/to/transcript.T /dev/null ~/transcript/obsolete/transcript.timestamp.T every time I wanted to back up a transcript before making a change, so I wrote a quick script to back up a transcript to a timestamped file:

#!/bin/bash

# Backs up a transcript to ~/transcript/obsolete

Transcript=$1
TranscriptNoPath="`echo $Transcript | awk 'BEGIN { FS = "/" } { print $NF }'`"
TranscriptNoEnding="`echo $TranscriptNoPath | sed -e \"s/\.T//\"`"
Today="`date +%Y%m%d`"
Target="/var/radmind/transcript/obsolete/${TranscriptNoEnding}.${Today}.T"

/usr/local/bin/lmerge -I $Transcript /dev/null $Target

Just change “/var/radmind/transcript/obsolete/? to whatever folder you want to use.

Posted by slauncha at 11:40 AM | Comments (0) | TrackBack

Set Hostname to Network-Supplied Hostname

Nobody wants their production machines to have hostnames like “Sites’ iMac.? To get around this issue, we created a script called HostNamer to find the hostname and set it. Under Tiger, we got away with calling hostname -s, but under Leopard this would often return the current hostname, not the desired one. So, we created a script to look at the DNS entry for the computer's IP address.

#!/bin/bash

# HostNamer - Gets proper hostname from server and tells OS X to use it.

PATH=/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin; export PATH

get_ip(){
        IPADDR="`/sbin/ifconfig en0 | awk '{ if ( $1 == "inet" ) print $2 }'`"
        IPBEGIN="`echo ${IPADDR} | awk '{ split($1, a, "."); print a[1] }'`"
}

# Get IP address.
get_ip

# Make sure that IP is valid (i.e. starts with "141.")  If not, wait and try again.
# Will only try 10 times.
count=0

while [ "${IPBEGIN}" != "141" ]; do
        let "count += 1"
        echo $count
        if [ $count -gt 10 ]; then
                logger -is Failed to get correct IP address.
                exit 1
        fi

        sleep 10

        get_ip
done

HOSTNAME="`host ${IPADDR} | awk ' { for ( x = 1; x < 20; x++ ) if ( $x == "pointer" ) print $(x+1) }' | awk '{ split($1, a, "."); print a[1] }'`"

scutil --set ComputerName "${HOSTNAME}"
scutil --set LocalHostName "${HOSTNAME}"
scutil --set HostName "${HOSTNAME}"

# Now, rename the disk.

# Get the correct disk name to use
DiskName="`diskutil list | grep -m 1 Apple_HFS | awk '{ print $NF }'`"

diskutil rename $DiskName $HOSTNAME

The portion that checks for a correct IP (for us, 141) is there because on Intel-based Macs, we noticed that the script was called before the network was up—we’re running it via a StartupItem. We also created a link to this script in our Radmind post-apply folder, so the system will be renamed before rebooting. That way, it comes up with its correct name. Finally, we rename the hard disk to the hostname to allow for easy identifiation of in-use computers.

Posted by slauncha at 09:56 AM | Comments (0)

May 19, 2008

Angell Hall Cyberstation - Color Printing fix

We will be deploying the 'pstoxeroxps' client-side cups filter to the Angell cyberstations this evening to resolve the Xerox 7400 Color Phaser 'paused' queue printing issue we identified last week. Both the 'pstophaserps' and 'pstoxeroxps' filters are noted dependencies in the Xerox PPDS.

Posted by rdevine at 04:30 PM | Comments (0)

Angell Hall Fishbowl Cyber - Leopard Deployment

We have deployed our Leopard loadsets to the Angell Hall Fishbowl cyberstations this afternoon. These machines will be upgrading to leopard on next user logout or nightly maintenance session, whichever should occur first.

Posted by rdevine at 04:18 PM | Comments (0)

May 15, 2008

Angell Hall Cyberstation - Leopard Deployment

As part of our Leopard migration process, we upgraded the Angell Hall Cyberstations (stations 3-28) to Leopard today. Pending feedback, we plan to upgrade the Angell Fishbowl cyberstations and the Angell Hall/SEB consultant workstations with our full-use Leopard offering within the next few days. Currently, the Angell Hall Color printer is not functioning properly in the Angell Cyberstation loadset and we are currently working on this issue. Enjoy!

Posted by rdevine at 07:58 PM | Comments (0)

May 07, 2008

Using iHook in Leopard Over the Login Window

After upgrading a station to Leopard, we recently noticed that our nightly script that starts our Radmind scripts (using iHook) was failing. Upon looking at the logs I realized that this was because of one of Leopard’s new security features: applications cannot open a GUI window over the login window without both being written specifically to do that and being called from a LaunchAgent. iHook version 1.1.1 is compatible with running this way, so the only thing one needs to do is create a LaunchAgent to do so. This thread from the Radmind Users mailing list illustrates this, with a sample LaunchAgent plist.

Posted by slauncha at 03:42 PM | Comments (0) | TrackBack