AppleScript front end to a shell script?

meancode

Registered
hello, i have this shell script that is working very well, and i would like to make it double clickable. i would like to use an AppleScript GUI for it. the script is commented to hell, this is b/c the admins that will use it are not very unix savvy. right now i have it in the unix path (/usr/bin) so i can just run it whenever i want, wich works. but the more "user friendly" the better in this case.

a little background: we are not giving users "home" directories on OS X Server, we are using a netinfo parent with child servers, and are not going to set them up with "home" directories. this script created a sudo home directory on the file server, wich is a child of the netinfo parent.
Code:
#!/bin/sh
# This script creates a staff folder for the user designated from the command line
# Note that this script does require administrator permissions.  It will prompt for
# an admin password as soon as it tries to create the new directory (first line with sudo)

# if there are no arguements, then we will need to read one from the user
if test "$#" -lt "1" ; then
    echo Create a Staff Folder for whom?
    read nuser
    set $nuser
fi

# while we still have something on the command line, move it into "user" for processing
# note that the user and the directory have the same name, so the variable is often referenced
# twice.

for user
do
# wait 3 seconds so you can read the output lines.
    sleep 3
    clear
# check to make sure that the directory does not already exist.  If it does,
# then do nothing and bail out
    if test -e "$user" ; then
        echo "There is already a Staff Folder called $user!!"
        echo "Contents are untouched, exiting......"
        exit
    fi

# OK, now that everything has been checked out, actually do stuff
    echo "Attempting creation of $1 staff folder"
    sudo mkdir "/Volumes/Contents\ 3/Private/$user"
    echo "Directory created, setting ownership..."

# set the owner of the directory to the user (note that they have the same name
# the only way that the chown command can fail is for the user not to exist
# therefore, if the chown command fails, then we should create the user before
# trying to run the script again.
    sudo chown "$user" "$user" || {
        echo "Staff member must have an account to have a staff folder"
        echo "Please create this user on DVA in the serveradmin application and"
        echo "run this script again for $user"
        echo "Removing directory"
        sudo rmdir "$user"
    }

# OK, if we've gotten here, and the directory still exists, then we can
# change the permissions for the directory.
# the chmod command will give read, write, and execute permission (7) to the owner (the new user),
# only write permission (2) to the group (staff) and no permissions to the world (0)
    if test -e "$user" ; then
        sudo chmod 720 "$user"
        sudo chgrp staff "$user"
    fi
done
# repeat the process until we run out of arguements (which were the users, remember?)
# OK, we're finished, give a listing of the directory to make sure everything worked
# the way it's supposed to.
ls -l

i have a similar script for archiving and deleting these staff folders, and would like to wrap a GUI around that one as well, but i figure if it is possable to do it to this one, the rest should be self explanitory.

my second question is can i do this entirely is AppleScript (and therefore not need to use a shell script at all? i suppose i could but i understand more about shell scripting at this point than i do about AppleScript. if i can do this in AppleScript, i was wondering if some kind soul here could show/tell me how. thanks in advance.
 
Back
Top