How can I automate the creation of a new system using scripts in Mac OS X 10.6?

I have been working on this for several days, but just can't find the right links to make it work.

The idea is to have a script that will be based on recently acquired Mac computers that are part of the company with basic materials such as setting up an autologin, creating a new admin user (for remote administrators to access support, setting a password to unlock the screen saver and etc.).

An example list for a baseline that administrators must run on each new machine:

  • Click the "Login Settings" button. Set auto login: OFF.
  • Check: Show reset, sleep and shutdown buttons
  • Uncheck: display the input menu in the login window
  • Uncheck: show password hints
  • Clear the checkbox: using voice in the login window
  • Check: Show shortcut user menu as short name

    (note: this is only part of a long list for each machine)

I managed to find some links to make some parts work. How autologin can be canceled with:

defaults write /Library/Preferences/.GlobalPreferences com.apple.userspref.DisableAutoLogin -bool TRUE 

and I found ways of thinking when creating a new user (including tooltips) using AppleScript commands and shell.

But, as a rule, this is a difficult search for ways to do a few simple things, such as including a password to exit the screen saver or to quickly switch users. The links are too limited or simply not where you can see (for example, I can turn off autology via cli, but the next setting in the system preference "show restart, sleep and shutdown buttons" is somewhere else, and I can’t find which one Either the command line so that it is installed)

Does anyone have any ideas on a list, a document, a link, or any of where all the settings in the system are, so that I can point out to make it work? or maybe sample scripts for the above example ...

My thanks for reading so far - many thanks for the one who has the information about this above.

+4
source share
2 answers

In general, the location of the various settings is not documented, but, as a rule, it is not so difficult to determine.

One way to do this is to change the setting and see which files (files) will be changed. fseventer is suitable for this, or if you have Xcode installed, you can use Packagemaker (run the snapshot package, change the setting, and then stop recording and see which files are listed as modified in the snapshot), or just run sudo fs_usage -ew ( and sort its plentiful output).

Once you find the appropriate file (s), change the settings back and forth to see how they change. If the files are .plists, you can use defaults to flush them before and after and compare, or use plutil -convert xml1 to switch them from binary to a readable XML format and compare by eye. Note that sometimes you can make several changes; for example, when disabling autologin, you really must remove the autoLoginUser key from /Library/Preferences/com.apple.loginwindow.plist, and also delete the / etc / kcpassword file.

Another way to find custom settings is to use the Apple preference tool based on the Workgroup Manager server. You can install the Apple server administration tools on a non-server and play with it locally:

  • run / Applications / Server / Workgroup Manager.app
  • when it asks for a connection to the server, select the menu item "Server"> "View Directories" instead
  • authenticate as an administrator (lock button in the upper left, right)
  • select the list of computer accounts (the rectangle icon in the row of small tabs in the upper left corner)
  • create a fictitious computer account (the "New computer" button on the toolbar)
  • go to the prefix management section (the "Settings" button on the toolbar)
  • there will be a bunch of categories of controlled preferences (most of them you mentioned in the "Login" section); do whatever interests you.
  • go to the "Details" tab, and you can see which preference domain (in essence, the name of the .plist file) and preference keys are controlled.

You can also get additional settings (in addition to those on the "Overview" tab) for applications that contain a preference manifest: in the "Details" section, click the "+" button, select an application, then open the corresponding preference domain and try to add keys to various sections; if the application has a manifest, clicking on the name of the preference key will give you a pop-up menu of available keys, and selecting one will be automatically filled with the value type, default value and a description of what it does. There are some really interesting options in the manifest for /System/Library/CoreServices/ManagedClient.app; check it out.

Some settings are intended for each user, which means that if you want to apply them to existing accounts, you will have to change the script / Users / * / Library / Preferences / whatever, and you may also want to edit the user template (/ System / Library / User Template / English.lproj / Library / Preferences / whatever), so subsequently created accounts will get the settings. In addition, some settings are for each user and for each computer; they are stored in ~ / Library / Preferences / ByHost with the computer identifier (Ethernet MAC address or hardware UUID) in the file name; use defaults -currentHost to set them.

If you make a bunch of changes to a single file (for example, prefs loginwindow), it may be easier to just copy the pre-configured settings file rather than modify the existing file.

For a better way to create an account creation script, see this server question and / or take a look at the createUser script package included with instadmg .

If you are deploying a lot of these computers, it might be worth taking a look at their image rather than personalizing them. Check out Apple System Image Utility , DeployStudio , and various discussions and tools on afp548 . There is also an Apple training class on deployment (bias expression: I am one of the trainers for this class, so I think everyone should attend this), or you can buy the class directory separately.

Edit: I forgot to mention the systemsetup and networksetup commands - for the settings that they cover, this is the best way.

+3
source

I don’t know where to find authoritative documents ... perhaps on developer.apple.com or in one of the system administrator certification guides. However, I can tell you that the hin input menu and password are in the /Library/Preferences/com.apple.loginwindow domain using the showInputMenu keys (boolean - false or no key for off) and retriesUntilHint (integer,> = 1 enabled, 0 or does not exist) respectively.

you can always use defaults domain to list all available default domains, and then try to determine what kind of dominance you think something will be from. Or you can try defaults find <somestring> , but sometimes the configuration is unclear, so just dumping a suspicious domain will be easier. Of course, if the default value needs to be configured, the key will not be even the most likely ... therefore, if you need to use this approach ... first turn on everything so that the key is installed.

0
source

Source: https://habr.com/ru/post/1334806/


All Articles