aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-04-16 10:29:14 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-04-16 10:29:14 +0300
commitaa769552aca49384e3ccb0d155aa238a4ac3de34 (patch)
treedaaa8c9e1a12ecc76970ef774e9a5fc996062bad
parent7e0e116d4fc2a3d57e125770266e402f67ee815f (diff)
downloadmtk-aa769552aca49384e3ccb0d155aa238a4ac3de34.tar.gz
mtk-aa769552aca49384e3ccb0d155aa238a4ac3de34.tar.bz2
mtk-aa769552aca49384e3ccb0d155aa238a4ac3de34.zip
Added new files
-rwxr-xr-x[-rw-r--r--]bloop.command2
-rwxr-xr-xmob2loc.sh56
-rw-r--r--nyetboot.command0
-rw-r--r--useradd.sh110
4 files changed, 168 insertions, 0 deletions
diff --git a/bloop.command b/bloop.command
index 67b292a..45e643e 100644..100755
--- a/bloop.command
+++ b/bloop.command
@@ -22,6 +22,8 @@ find "$MYDIR/" -exec open {} \;
trap "killall yes; rm ${MYDIR}; echo 'Cleaning up...'; exit 255" SIGINT
sleep 10
+# Time how long it took to boot up
+#...
echo $(date) >> ~/Desktop/blooper.log
#reboot
diff --git a/mob2loc.sh b/mob2loc.sh
new file mode 100755
index 0000000..aa931fc
--- /dev/null
+++ b/mob2loc.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+# Convert Mobile account to Local
+
+if [[ $USER != "root" ]]; then
+ echo "This tool must be run as root" >&2
+ exit 1
+fi
+
+usage="$(basename $0) username password"
+
+if [[ $# -lt 2 ]]; then
+ echo $usage 2>&1
+ exit 1
+fi
+
+username=$1
+password=$2
+
+# First check that user exists
+homedir=$(dscl . read "/users/$username" NFSHomeDirectory | sed 's/.*: //')
+
+if [[ ! -d $homedir ]]; then
+ echo "Invalid user $username" >&2
+ exit 1
+fi
+
+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_gid=$(nextid /groups PrimaryGroupID)
+
+newhome="/Users/$username"
+
+# Delete mobile account
+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 $new_shell
+dscl . -create /users/$username GeneratedUID $(uuidgen)
+dscl . -create /users/$username PrimaryGroupID $new_gid
+dscl . -create /users/$username NFSHomeDirectory $newhome
+
+# Give admin perms
+dscl . -append /groups/admin users $username
+
+# Set the password
+dscl . -passwd /users/$username "$password"
+
+# Set correct permissions
+chown -R $username:staff
diff --git a/nyetboot.command b/nyetboot.command
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nyetboot.command
diff --git a/useradd.sh b/useradd.sh
new file mode 100644
index 0000000..9ad307f
--- /dev/null
+++ b/useradd.sh
@@ -0,0 +1,110 @@
+#!/usr/bin/env bash
+# useradd.sh v1.2
+# (cc) 2006 Filipp Lepalaan <filipp@mac.com>
+# Updated to support both Tiger & Leopard <filipp@mac.com>
+# Updated for Leopard by Allan Sanderson <allanbee@mac.com>
+# Included non-interactive password setting - this is a contencious issue for
+# many, but it fits with what I need it to do!
+
+usage="sudo $(basename $0) [-u uid] [-g group] [-a] [-c] [-d home] \
+ [-p passwd] [-s shell] [-rn realname] name"
+
+if [ $# -eq 0 ]
+ then echo "Usage: $usage" >&2;
+ exit 1
+fi
+
+# Thnx to pea!
+if [ $USER != "root" ]
+ then echo "$(basename $0) must be run as root" >&2
+ exit 1
+fi
+
+# Some defaults
+def_shell=$SHELL
+def_home='/Users'
+make_home=true
+make_admin=false
+set_home=false
+make_passwd=true
+def_passwd=$(cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2)
+
+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_gid=$(nextid /Groups PrimaryGroupID)
+
+os_ver=$(sysctl -n kern.osrelease);os_ver=${os_ver:0:1}
+
+while getopts "u:g:acd:p:s:rn:" param
+do
+ case $param in
+ u ) new_uid=${OPTARG:-$new_uid};;
+ g ) new_gid=${OPTARG:-$new_gid};;
+ a ) make_admin=true;;
+ c ) make_home=true;;
+ d ) set_home=true; new_home=${OPTARG:-$new_user};;
+ p ) new_passwd=${OPTARG:-$def_passwd};;
+ s ) new_shell=${OPTARG:-$def_shell};;
+ rn ) new_fn=${OPTARG:-$def_rn};;
+ esac
+done
+
+shift $(($# - 1)); new_user=$1 # Get the last argument
+
+# Check if user already exists
+dscl . -read /Users/$new_user &> /dev/null
+if [ $? -eq 0 ]
+ then echo "Error: user $new_user already exists" >&2
+ exit 1
+fi
+
+# Set to default if not given
+new_rn=${new_fn:-$new_user}
+new_shell=${new_shell:-$def_shell}
+new_passwd=${new_passwd:-"$def_passwd"}
+new_home=${new_home:-"$def_home/$new_user"}
+
+# Process user record
+dscl . -create /Users/$new_user UniqueID $new_uid
+dscl . -create /Users/$new_user RealName "$new_rn"
+dscl . -create /Users/$new_user UserShell $new_shell
+dscl . -create /Users/$new_user GeneratedUID $(uuidgen)
+dscl . -create /Users/$new_user PrimaryGroupID $new_gid
+
+# Process group record
+if [ $os_ver -lt 9 ]
+ then dscl . -create /Groups/$new_user PrimaryGroupID $new_gid
+ dscl . -create /Groups/$new_user GroupMembership $new_user
+fi
+
+# Create home directory
+if [ $make_home == true ]
+ then echo "Creating $new_home"
+ cp -r /System/Library/User\ Template/English.lproj/ $new_home
+ cp -r /System/Library/User\ Template/Non_localized/* $new_home/
+ chown -R $new_user:$new_gid $new_home
+ set_home=true # Otherwise this'd be pretty pointless
+fi
+
+if [ $set_home == true ]
+ then dscl . -create /Users/$new_user NFSHomeDirectory $new_home
+fi
+
+if [ $make_admin == true ]
+ then echo "Adminning $new_user"
+ dscl . -append /Groups/admin users $new_user
+fi
+
+if [ $make_passwd == true ]
+ then echo "Setting password for $new_user"
+ dscl . -passwd /Users/$new_user "$new_passwd"
+fi
+
+echo "User $new_user ($new_uid) created, password: $new_passwd"
+
+exit 0