"reset" users home dir to archived content

We are used to use a SMB-based network homedir for students in our labs. Unfortunately this does no longer work with current macOS versions (Apple case 101442640823). Therefore we need a workaround.

My idea is to use a standard user account which is reseted daily. Therefore I created "USER" and made the initial setup after the first login. My plan was to create a tar-active and a launchdaemon script which does remove /Users/USER and extract the tar archive to get a fresh USER home.

This does not work: I cannot remove as root the old home dir via "rm -rf /Users/USER" due to permission errors.

I want not remove and re-create the user via dscl because the initial first login setup should not be needed every day. I want to reset USERS home to an archived backup of a defined status.

Any clue how to solve this issue?

Answered by GreatOm in 779359022

Meanwhile I got a solution I want to share here: It seems so that the OS has some "voodoo" to protect used home directories. So a change of users home dir via

dscl . -change /Users/USER NFSHomeDirectory /Users/USER /doesNotExist

allows removing the HOMEDIR and re-create it from a template. Afterwards the command

dscl . -change /Users/USER NFSHomeDirectory /doesNotExist /Users/USER

does set the homedir back to the old value.

Accepted Answer

Meanwhile I got a solution I want to share here: It seems so that the OS has some "voodoo" to protect used home directories. So a change of users home dir via

dscl . -change /Users/USER NFSHomeDirectory /Users/USER /doesNotExist

allows removing the HOMEDIR and re-create it from a template. Afterwards the command

dscl . -change /Users/USER NFSHomeDirectory /doesNotExist /Users/USER

does set the homedir back to the old value.

"reset" users home dir to archived content
 
 
Q