I’ve inherited the following script to create accounts in OSX.
I’d like to include a check into it that first checks to see if an account already exists on the destination with that name, and if so, echoes a message “Account Exists”, then takes no other action and then moves on.
A typical /tmp/list.txt consists of just shortnames, I.e.:
jdoe
brianx
peterm
smithd
Your help is much appreciated!
#! /bin/sh
if [ $# -ne 1 ]
then
echo mkhdir: Did not find required argument: group name
echo Usage: mkhdir \[group\]
exit 1
fi
for i in `cat /tmp/list.txt` ; do
if [ ! -r /Volumes/UserStorage/Users/$i ]
then
mkdir /Volumes/UserStorage/Users/$i
mkdir /Volumes/UserStorage/Users/$i/Backups
fi
chown -R $i:$1 /Volumes/UserStorage/Users/$i
chmod -R 700 /Volumes/UserStorage/Users/$i
find /Volumes/UserStorage/Users/$i -type d -exec chmod 701 {} \;
done
The test for
[ ! -r ... ]won’t tell if you /Volumes/UserStorage/Users/$i is a directory or not. Use701Anyone know what the purpose is for701in the finalfind ... chmod?IHTH