I am trying to write a startup script to add a user account upon boot for a modular image I am creating. I have properly formatted a plist file placed in the LaunchDaemons folder.
and written this script, which I know works when executed with sudoers privileges
I know that startup scripts are run with the sudo account. So I can't see why this isnt working. I already used
to make sure the apple setup assistent doesnt run. I ran
where XXX is the filename for both the plist and the shell script to make sure permissions are correct. Any ideas on what the problem might be?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.berry.postimage</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/postimage.sh</string>
</array>
</dict>
</plist>
Code:
#!/bin/bash
sudo dscl localhost create /Local/Default/Users/testuser
sudo dscl localhost create /Local/Default/Users/testuser RealName "Test User"
sudo dscl localhost create /Local/Default/Users/testuser PrimaryGroupID 0
sudo dscl localhost create /Local/Default/Users/testuser UniqueID "505"
sudo dscl localhost create /Local/Default/Users/testuser UserShell /bin/bash
sudo dscl localhost create /Local/Default/Users/testuser NFSHomeDirectory /Users/testuser
sudo dscl localhost -passwd /Local/Default/Users/testuser "xxx"
mkdir -p /Users/testuser
sudo ditto -rsrc -V "/System/Library/User Template/English.lproj/" /Users/testuser
chown -Rf testuser:admin /Users/testuser
sudo dscl localhost -append /Local/Default/Groups/admin GroupMembership testuser
touch /var/db/.AppleSetupDone
sudo rm /Library/LaunchDaemons/postimage.plist
I know that startup scripts are run with the sudo account. So I can't see why this isnt working. I already used
Code:
sudo /var/db/.AppleSetupDone
Code:
sudo chown root:wheel XXX