Showing posts with label Bash. Show all posts
Showing posts with label Bash. Show all posts

Tuesday, March 25, 2008

Pashua

I have been looking for a way to add Mac GUI elements to my shell scripts without have to learn xcode. Here it is: "Pashua ist a tool for creating native Aqua dialog windows for...shell scripts..."

Pashua is freeware, not open source, and you are limited to one of each input element. Otherwise I think it is going to serve me quite well.
The limitations of Pashua can be overcome by with loops and next buttons.
I plan to add this to the bundle of software I install with LHPG. The other two applications I install are Quota Menu Monitor and Keychain Minder.

Thursday, March 13, 2008

Add second shortname to OD Users

Micah Baker, the other day asked me about adding a secondary shortname to OD users.

So how do you add a secondary short name? We could use WorkGroup Manger, but I like the command line and automation.
So I use dscl the command line directory services utility. See the dscl man page here
dscl -u (OD-DIR-ADMIN) -P (PASSWORD) /LDAPv3/(ODMASTER-DN) -append Users/(SHORTNAME) uid (SHORTNAME TO ADD)
Micah had first_last as the username, and wanted to add first.last to all his users.
So through a script together.

#!/bin/bash -
# Eden Nelson 3/12/08
# add shortname

#Please set these vars!!!
# OD Master DNS
ODMASTER=
# OD Dir Admin
ODADMIN=
# OD Dir Admin Pass
ODPASS=
#Temp file where usernames are kept
TEMPFILE=/tmp/default.tmp
#Sleep between operations, keep the script from hammering the ODM
SLEEP=3

## ##
# Script Starts Here #
## ##

trap "{ rm -f $TEMPFILE ;}" EXIT SIGINT SIGTERM

dscl /LDAPv3/"$ODMASTER" -list Users > "$TEMPFILE"

cat "$TEMPFILE" | \
while read USERNAME
do

FIRSTNAME=`echo $USERNAME | cut -d'_' -f 1`
LASTNAME=`echo $USERNAME | cut -d'_' -f 2`

dscl -u "$ODADMIN" -P "$ODPASS" /LDAPv3/"$ODMASTER" -append Users/"$USERNAME" uid "$FIRSTNAME"."$LASTNAME"

sleep "$SLEEP"

done

exit 0