Logout Script Question

grecopj
Contributor

Hi All,

I currently use a script on logout in my labs that deletes the user's account. It keeps some local admin accounts but deletes the rest.

All works great in my Sierra and High Sierra environments. However in my testing with Mojave it keeps the last user when I login in with another. Then if I was to log out it keeps that last one but deletes the previous one. Hope that makes sense.

Login with USER A
Logout USER A
Login with USER B
If I look in the users folder, USER A is still there
Logout USER B
Login with USER C
If I look in the users folder, USER A is gone but USER B is still there.

Here is the script I am using. I actually got this form another user on the forum and thank you for that.

for dir in /Users/* do if [ ! "$dir" = "/Users/admin" ] && [ ! "$dir" = "/Users/viscom" ] && [ ! "$dir" = "/Users/root" ] && [ ! "$dir" = "/Users/main" ] && [ ! "$dir" = "/Users/Shared" ] ; then echo ${dir} rm -R $dir dscl . -delete $dir fi done

exit 0

Any suggestions would be greatly appreciated.

1 ACCEPTED SOLUTION

grecopj
Contributor

So, this actually is not as bad as I thought. It keeps the folder of the previous user but that folder has no contents. I think I am going to leave as is. Thanks to anyone that was looking into it.

View solution in original post

1 REPLY 1

grecopj
Contributor

So, this actually is not as bad as I thought. It keeps the folder of the previous user but that folder has no contents. I think I am going to leave as is. Thanks to anyone that was looking into it.