Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Top Background
 
Search
 
 
Miscellaneous
Show/Hide Hidden Files E-mail
Written by Chad Barraford   
Friday, 25 May 2007
Here is a simple applescript that toggles show hidden files in Finder. Someone in the comments stated that it doesn't work unless the key "ShowAllFiles" in your Finder plist is there, which by default, its not there. I revised the script to account for that.
Last Updated ( Thursday, 03 January 2008 )
Read more...
 
Group Membership Script E-mail
Written by Sam Agnew   
Monday, 28 August 2006
This is a bash script that gives you the membership of any Open Directory group whether it contains other nested groups or not. In "debug" mode it gives you all information about whether a group contains other nested groups, what those groups are and what members are direct members rather than inherited.

Usage: ./grouplister.bash [-debug]

Example: ./grouplister.bash staff For a list of all members of group with shortname of "staff"

Example: ./grouplister.bash staff -debug For full information about group membership of group with shortname of "staff" and nested groups

Last Updated ( Monday, 30 October 2006 )
Read more...
 
Cornell Namer E-mail
Written by Sam Agnew   
Wednesday, 09 November 2005
This is something I've been wanting to make public for some time now. In the dusty back archives of macosxlabs is my old StartupItem version of this which depended upon ncutil.

The new version (well, not new here but...) uses launchd and scutil so no extra software. We've been running it fine here on everything since 10.4 came out:

Click here to download the Cornell Namer.

Instructions:

Copy cornellnamer.plist to /Library/LaunchDaemons
Create /Library/AdminItems and copy cornellNamer.sh to this directory
Edit the dnsbase variable as appropriate for your domain

The script assumes that you have static IPs and a DNS that names each computer uniquely (in our case the name matches the asset tag for the machine)

cornellNamer.sh:

#! /bin/sh
#
# Cornell Computer Namer
# Modifications by
# Sam Agnew
# Weill Cornell Medical College in Qatar
# January 22, 2004
#
# Based upon
# Panther Post-Image Setup SPRING 2004
# ComputerName
# January 9, 2004
#
# Now launched via launchd
# Now using scutil
# Now using qatar-med.cornell.edu
# Sam Agnew
# July 31, 2005
# Minor cleanup for release November 9, 2005

test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
# Max wait for network in seconds / 2
limit=60
# Set domain name base here
dnsbase=".qatar-med.cornell.edu"

# Set Initial Name and try to make it unique
TEMPNAME="Waiting-for-network${RANDOM}"
scutil --set ComputerName $TEMPNAME
scutil --set LocalHostName $TEMPNAME

# Wait for network
X=0
while [ $test != 1 ]
do
        echo Network not currently up
        test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
        X=$((X+1))
        if [ $X -ge $limit ]; then
                break
        fi
        sleep 2
done

HWADDRESS=`ifconfig en0 | grep ether | awk '{print $2}'`
IPADDRESS=`ifconfig en0 | grep inet\ | awk '{print $2}'`
COMPUTERNAME=$(host $IPADDRESS | awk '{ print $5 }' | sed s/${dnsbase}.//)

###### IF COMPUTERNAME IS BLANK, SET NAME TO HWADDRESS, OTHERWISE SET  TO VALUE CALCULATED FROM DNS LOOKUP ######
if [ "$COMPUTERNAME" = "no" ]; then
    NONAME="`echo $HWADDRESS`-DHCP-Error"
    scutil --set ComputerName $NONAME
    scutil --set LocalHostName $NONAME
elif [ "$COMPUTERNAME" = "" ]; then
    NONAME="`echo $HWADDRESS`-Network-Connection-Failure"
    scutil --set ComputerName $NONAME
    scutil --set LocalHostName $NONAME
elif [ "$COMPUTERNAME" = "3(NXDOMAIN)" ]; then
    NONAME="`echo $HWADDRESS`-No-DNS-Record-For-Host"
    scutil --set ComputerName $NONAME
    scutil --set LocalHostName $NONAME
else
    scutil --set ComputerName $COMPUTERNAME
    scutil --set LocalHostName $COMPUTERNAME
fi

if [ $(who|grep console|wc -l) == 0 ]; then
    if [ $(ps wwaux|grep WaitingForLoginWindow|grep -v grep|wc -l) == 0 ]; then
        killall loginwindow
    fi
fi
killall syslogd

cornellnamer.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>edu.cornell.qatar-med.cornellcomputernamer</string>
        <key>ServiceDescription</key>
        <string>Names computer based upon DNS resolution</string>
        <key>RunAtLoad</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
                <string>/Library/AdminItems/cornellNamer.sh</string>
        </array>
</dict>
</plist>

Last Updated ( Wednesday, 09 November 2005 )
 
OFPW: Open Firmware Password Tool E-mail
Written by macenterprise   
Wednesday, 23 February 2005
ImageImageImage This command line tool ("OFPW") can set the Open Firmware security-mode and security-password, when executed with sudo or as the "root" user context (ie, from within Login and Logout Hooks, logged in as root, etc.).
Last Updated ( Tuesday, 24 January 2006 )
Read more...