I want to run a couple of .sh scripts when the user first login after user creation to set the correct settings. I know there is a folder (/Library/StartupItems) that let you place script for running on every startup, but is there something like that for first time logon?
MacOS – Run script when new user logon the first time
bashloginlogin-itemsmacosuser-account
Related Question
- How to run a script on login whilst being hidden
- MacOS – Run Script on Logout Without Use of Logout Hook
- IMac – Login – Screen Flashes and Returns to Login Screen – Terminal Explanation
- MacOS – Pressing first letter of user account name does not select user in login window
- Run script on login *as root* on Catalina
- Closing Terminal window does not kill script run with sudo
- Script menu: how to reference user-path utilities (PATH / environment is missing)
Best Answer
I don't know of a specific place on OS X, but a pretty common way to handle this is just to have the script run every time the user logs in, and check for the presence of a specific hidden file in the user's home directory. If the hidden file is there, do nothing and exit. If it's not there, run the first-time login procedure, and create the hidden file.
Note also the "/System/Library/User Template/[locale]" directory, which is the skeleton home directory used to create all new users' home directories. You may be able to use this to achieve what you want.
Have a look at: Modifying OS X User Template