aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-04-16 10:45:41 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-04-16 10:45:41 +0300
commit5b41bcc780ab746e4c4881fb3edea454dc4c2ac9 (patch)
tree1a0e95a593d66a91fa4b1fec81ab804fa66fdf78
parentcfdfbc406a80711c527c71c04ac090d0fc34a591 (diff)
downloadmtk-5b41bcc780ab746e4c4881fb3edea454dc4c2ac9.tar.gz
mtk-5b41bcc780ab746e4c4881fb3edea454dc4c2ac9.tar.bz2
mtk-5b41bcc780ab746e4c4881fb3edea454dc4c2ac9.zip
mob2loc fixes
-rwxr-xr-xmob2loc.sh24
1 files changed, 14 insertions, 10 deletions
diff --git a/mob2loc.sh b/mob2loc.sh
index 8dc7e71..1049ab9 100755
--- a/mob2loc.sh
+++ b/mob2loc.sh
@@ -17,40 +17,44 @@ username=$1
password=$2
# First check that user exists
-homedir=$(dscl . read "/users/$username" NFSHomeDirectory | sed 's/.*: //')
+homedir=$(dscl . read "/Users/$username" NFSHomeDirectory | sed 's/.*: //g')
if [[ ! -d $homedir ]]; then
echo "Invalid user $username" >&2
exit 1
fi
+realname=$(dscl . read "/Users/$username" RealName | sed 's/.*: //g')
+
nextid() {
max_id=$(dscl . -list $1 $2 | awk '{print $2}' | sort -n | tail -n 1)
(( max_id++ ))
echo $max_id
}
-new_uid=$(nextid /users UniqueID)
+new_uid=$(nextid /Users UniqueID)
new_gid=$(nextid /groups PrimaryGroupID)
newhome="/Users/$username"
# Delete mobile account
-dscl . -delete /users/$username
+dscl . -delete /Users/$username
# Create local user
-dscl . -create /users/$username UniqueID $new_uid
-dscl . -create /users/$username RealName "$new_rn"
-dscl . -create /users/$username UserShell "/bin/bash"
-dscl . -create /users/$username GeneratedUID $(uuidgen)
-dscl . -create /users/$username PrimaryGroupID 20
-dscl . -create /users/$username NFSHomeDirectory $newhome
+dscl . -create /Users/$username UniqueID $new_uid
+dscl . -create /Users/$username RealName "$realname"
+dscl . -create /Users/$username UserShell "/bin/bash"
+dscl . -create /Users/$username GeneratedUID $(uuidgen)
+dscl . -create /Users/$username PrimaryGroupID 20
+dscl . -create /Users/$username NFSHomeDirectory $newhome
# Give admin perms
dscl . -append /groups/admin users $username
# Set the password
-dscl . -passwd /users/$username "$password"
+dscl . -passwd /Users/$username "$password"
# Set correct permissions
chown -R $username:staff $newhome
+
+exit 0