Skip to content

Instantly share code, notes, and snippets.

@rickychilcott
Created March 2, 2012 12:51
Show Gist options
  • Save rickychilcott/1958219 to your computer and use it in GitHub Desktop.
Save rickychilcott/1958219 to your computer and use it in GitHub Desktop.
MunkiServer Data Gather
#!/bin/sh
#Connect to server
REMOTE_DRIVE="/Volumes/DataRepo"
mkdir -p $REMOTE_DRIVE
/sbin/mount_afp "afp://server/MSJoiner" $REMOTE_DRIVE
#First Drive
LOCAL_DRIVE=${DS_LAST_RESTORED_VOLUME}
#mac address
MAC=`/sbin/ifconfig en0 | awk '/ether/ {print $2}'`
#computer name
COMP_NAME=`/usr/libexec/PlistBuddy -c 'Print System:Network:HostNames:LocalHostName' $LOCAL_DRIVE/Library/Preferences/SystemConfiguration/preferences.plist`
#Create file with with name {macaddress}.txt
DATA_FILE="$REMOTE_DRIVE/$MAC.txt"
#Write contents to file
echo $MAC > $DATA_FILE
echo $COMP_NAME >> $DATA_FILE
echo `ls $DRIVE/Users` >> $DATA_FILE
#Unmount from AFP
umount $REMOTE_DRIVE
rm -rf $REMOTE_DRIVE
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment