Home Forums OS X Server and Client Discussion Open Directory Batch Folder Create

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #375642
    Mark Cain
    Participant

    Is there a way to create a set of folders based on my list of users.

    I can export the users as a text list, but I have no idea how to then use this list to create a list of folders. Is this possible. Something like the createhomedir would be good, but I don’t want the folders to end up in the home folder location.

    Any advice would be greatly appreciated

    #375701
    arekdreyer
    Member

    I’m not the most elegant script writer, but I modified a script
    I already had for your purposes.

    [code]
    #!/bin/sh
    #
    # Create a folder for each user
    #
    # Arek Dreyer
    # [email protected]
    # Sun Mar 15 11:00:30 PDT 2009
    #
    #
    # Search for users in each node.
    # Note that if you search on the /Search/Users,
    # you may run into duplicate users (like root 0)
    # and this script’s assumptions fail.
    #
    # This script assumes that users under uid 1024 are system users; do not
    # create any home folder for those users.
    #
    # Modify the variable, depending on which node you’re interested in.
    #NODELIST=”/LDAPv3/127.0.0.1″
    NODELIST=”/Local/Default /LDAPv3/127.0.0.1″
    #NODELIST=”/LDAPv3/my.odm.com”
    #
    # Remove the following two lines if you don’t need
    # the script to change ownership of the folders for you
    # and don’t need to run the script as root.
    #
    echo “Note: $0 must be run as root”
    [ $UID -eq 0 ] || exit 1
    #
    # Comment out the following two lines when you’re done testing.
    /bin/mkdir /tmp/createfolder.$$
    cd /tmp/createfolder.$$
    #
    for NODE in ${NODELIST}; do
    echo “Processing node ${NODE}”
    for USER in $(/usr/bin/dscl ${NODE} -list /Users) ; do
    USERUID=$(/usr/bin/dscl ${NODE} -read /Users/${USER} \
    UniqueID | /usr/bin/cut -d” ” -f2)
    if [ ${USERUID} -gt 1024 ]; then
    /bin/mkdir ${USER}
    /usr/sbin/chown ${USER} ${USER}
    echo “Created folder for ${USER}”
    fi
    done
    done
    [/code]

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Comments are closed