#!/bin/bash
#
#管理员密码
Passwd=$(/usr/bin/osascript -e 'display dialog "请输入管理员密码" with hidden answer default answer "" with icon note buttons {"Continue"} default button "Continue"
set result1 to result
set the text_data to text returned of the result
set the button_data to button returned of the result1
if button_data = "Cancel" then
return ""
end if
return text_data')
if [ -z "$Passwd" ];then
exit 0;
fi
if [ $Passwd = 'aaaaaaaa' ]; then
sudo dscl . -create /Users/JS-temp UniqueID 550
sudo dscl . -create /Users/JS-temp PrimaryGroupID 20
sudo dscl . -create /Users/JS-temp NFSHomeDirectory /Users/JS-temp
sudo dscl . -create /Users/JS-temp UserShell /bin/bash
sudo dscl . -create /Users/JS-temp RealName "temp"
sudo dscl . -passwd /Users/JS-temp "1234"
sudo dscl . -append /Groups/admin GroupMembership JS-temp #这就是把创建的普通用户转为管理员
$(/usr/bin/osascript -e 'display dialog "已创建新的临时管理员 temp,密码为 1234 ,当临时处理完后,就删除此用户!" buttons {"OK"} default button "OK"')
echo "OK";
fi