在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):tiiiecherle/osx_install_config开源软件地址(OpenSource Url):https://github.com/tiiiecherle/osx_install_config开源编程语言(OpenSource Language):Shell 99.6%开源软件介绍(OpenSource Introduction):macOS Scripting for Configuration, Backup and RestoreHey to every macOS user ;) I am not a developer but an apple user and admin for more than 10 years. A clean install is generally a good way on every operating system to track down and avoid bugs. Additionally, old, no longer needed files in the system get deleted. Unfortunately, a clean install usually is time-consuming, especially when taking care of several devices. Therefore I initiated this project: to make clean installations (including restoring some already configured files from previous installations) and macOS configurations as simple, customizable and fast as possible by providing a walkthrough of a clean macOS install including manuals, scripts, comments and a lot of macOS intel. Furthermore I worked on some additional macOS scripts, e.g. homebrew and cask updates, security and ad-blocking by updating the hosts file or auto-selecting the network location based on ethernet connectivity, on demand and monitored virus scanning using clamav - to mention just a few. These are not designed for a one-time configuration but for (automatic) regular usage after installation. Of course, you can as well customize and run the commands and scripts on existing systems that did not lately get a clean install. All scripts and manuals are only optimized and updated for the latest available macOS and may or may not work on older versions. One main goal (which started it all) is to make the complete macOS System Preferences highly customizable by script. Partially, existing scripts and code snippets were embedded. For these the credit goes to their authors. I ordered the content of this script according to the macOS System Preferences and added configuration options for some default apple apps (Safari, Calendar, Contacts, ...). Additionally I wrote a backup and restore script for third party apps and their preferences files. Initially this was intended for my personal use only. However I decided to publish everything here as it took me so many hours and I would have appreciated to find anything like this when I started. So, I hope it helps anyone ;) Any help, feedback and comment for improvements and enhancements is welcome. There is a list of preferences I couldn`t figure out to set by script until now, so I would appreciate help for solving them and also for testing the functionality of the scripts and commands. Read this ReadMe including the disclaimer carefully before you start using anything and feel free to adjust every script and manual to your needs. Happy installing, customizing and enjoying macOS ;) Table of contentsDefault shell and config file Default shell and config fileIn macOS 10.15 zsh replaces bash as default shell. I took the chance to rewrite and improve all scripts in many different aspects and functionality. For optimization and easier maintenance I introduced a config file that is installed to The config file can be installed by using this command in the terminal:
From now on all scripts use zsh as default interpreter. At the time of the change (2019-07) all scripts are zsh and bash compatible, but further development is only being done for the default macOS shell, therefore zsh. Using bash instead of zsh can easily be achieved by using the bash shebang in the script. UsageDownload the complete github repository or single scripts, adjust everything to your needs and follow the instructions and manuals wherever needed. Some scripts depend on other scripts, so it is recommended to keep the directory structure and naming of files and folders. All
All The steps to be taken are consecutively numbered and meant to be done in the given order to make them work correctly as some scripts or manuals depend on completed previous ones. For easier maintenance most of the comments inside the scripts and manuals are not case sensitive and just written in small letters on purpose. Before deleting everything on your drive and starting a clean macOS install make sure you have at least one working backup of all relevant files. I recommend doing one backup with the backup script and another one on a second external device or partition using time machine. As mentioned above some scripts (e.g. homebrew-update, hosts, network-select, etc.) come with installer scripts that copy the needed files to the respective locations in the system and adjust their ownership and permissions. They can be used on a regular basis (some of them automatically) after installation. Batch InstallationAfter a lot of changes to the structure, the content, the config file and the default shell in the scripts it's finally possible (as of 2019-09, macOS 10.14 and newer) to combine most of them as a batch installer. After customizing and adjusting all scripts to your needs follow these steps:
This has the advantage that the scripts do not have to be run one by one. Instead the batch scripts sequentially processes all the scripts and play a sound when done. After each batch script check all outputs (and logfiles if needed) and reboot before starting the next one. This makes the install/restore itself easy, mostly unattended, clean and fast. 0 Bootable usb devicePreparationBefore starting with the clean install of macOS a bootable usb device is needed. This is how to create it.
Steps 1 and 2 can be replaced by using 0a_format_bootable_usb_device.sh. It formats the complete usb device into two partitions (installer and data) and gives you the option to delete the efi partition afterwards. This makes the data partition on the usb device usable on a win10 pc. InstallationTo perform the actual clean installation, boot the mac from the created usb device by restarting and holding the Select the usb device installer as startup volume. Inside the installer use disk utility to delete and format your drive with the file system of your choice. During this process I rename my drives to a label without whitespaces for easier terminal usage. That's why in all scripts of this project 1 NVRAM, system integrity protection and secure bootNVRAMScript 1a adjusts NVRAM parameters and therefore allows to manipulate firmware variables. System Integrity Protection (SIP)With macOS 11.10 El Capitan Apple introduced a new security feature named system integrity protection which prevents the user from getting root and thereby from making changes to specific system files and directories. If you want to disable SIP (partially or completely) follow these steps. Before you do that make sure you know what you are doing. Disable System Integrity Protection (partially or completely) in Recovery
If SIP is enabled
or multiple components can be disabled, e.g. for these scripts to work use: To disable SIP completely, use Disable Secure Boot in Recovery ModeAll Macs with T2 Chips, e.g. the MacBook Pro 2018 have an additional security feature which disables booting from external devices by default. To enable booting from external usb devices, follow these steps:
This can be reset for security reasons after finishing the installation. 2 PreparationsmacOS UpdatesScript 2a updates macOS on the command line if the system should not be up to date. Script 2b is a short manual and checklist which contains a few steps that have to be done before continuing with the next steps. zsh as default shell und customizationsInstall command line tools and set zsh as default shell incl. customizations with oh-my-zsh. 3 Homebrew, Casks and MasHomebrew is a really nice project and a package manager for macOS. In combination with homebrew cask it allows you to install and update command line software, players, plugins and apps on macOS on the command line. Mas makes it possible to install and update apps from the macOS appstore using the command line. You will find more information here: These scripts install macOS Command Line Tools, homebrew, homebrew-cask and mas. Additionally, they take the entries from separate list files and install homebrew formulas, apps from the App Store, macOS-plugins and macOS-apps in parallel mode. It is like downloading and installing them manually but a lot faster and more comfortable. To easily keep all packages and apps up-to-date a macOS-app Wrapper update script is also included and can be installed to /Applications using the dmg installer. 4 SSD OptimizationsDo not run this script if your volume is not an ssd. 5 Network ConfigurationTo avoid network issues this script deletes It can be run with profiles - to be easily usable on multiple macs - or standalone. More information can be found in the comments inside the script and in the example profile. To run the script with a profile, duplicate the example profile and name it To reset all network configurations and settings run the following commands in the terminal before running the script.
6 Manual app installationThis is just a checklist of apps to install manually if their installation is not possible by restoring or via homebrew cask. 7 Backup and restore scriptThis backup/restore tool is highly customizable, configurable and based on well-known command line tools. It is working well for years with multiple backups and restores on different macs. At first glance it seems a bit complicated but it really isn`t ;) When running the script by double clicking the The lines in the All lines that get backed up or restored start by u (user) and the script does a syntax check of the backup_restore_list.txt file at the beginning. Lines that are commented out are ignored and the echo lines will be displayed in the Terminal while running. Over time the script gathered more and more backup options for different purposes, e.g. an applescript for backing up calendars, contacts and reminders using the GUI. To make usage for multiple users easier and faster it can be run with profiles. More information can be found in the comments inside the script and in the example profile. To run the script with a profile, duplicate the example profile and name it restoreMake sure you only restore files and folders this way that were backed up with this script, so they have the correct structure inside the backup/restore directory. Select the folder containing the backup files when the script prompts for the respective input. Use generalAt the end of the restore process the script also resets the permissions in the If there are any questions, feel free to ask. And, of course, any help to make this better and easier is always appreciated. 8 Java 6Not a lot of applications still use java 6 on macOS. To make them work without installing apple java uncomment the options inside and run this script. Before running the script download and install the latest version of java (jre) from java.com or adoptopenjdk. Alternatively install one of them through homebrew-cask. 9 launchdlaunchd is a unified operating system service management framework which starts, stops and manages daemons, applications, processes and scripts on macOS. As it is sometimes very helpful to run scripts on boot (as root or user), at login or at logout, these scripts show how to do that. They come with installer scripts and are highly configurable. AdBlocking by extensions and /etc/hosts (as root, on boot)As Adblocking is important on the internet, this script combines adblockers and entries in the /etc/hosts file for best possible speed and adblocking results. It contains a manual for configuration and a script to install the /etc/hosts entries, as well as a launchd service that keeps it up to date on a given intervall. The script uses this project to update the hosts file. Local certificate check and installation (as root, on boot)Even on a local network it is recommended to use SSL certificates to encrypt connections to other computers on the network. SSL certificates can’t be issued for auto-acceptance for local LAN connections and therefore they have to be accepted explicitly. If a certificate is issued by letsencrypt it gets renewed on a regular basis. This script checks if the certificate was renewed and auto-adds it to the keychain to allow local LAN usage without re-accepting the certificate every time it is renewed. Auto network selection (as root, on boot)The network configuration script offers the possibility to add different locations, devices and settings to the network preferences. If, for example, a MacBook is used via ethernet in combination with a static IP in the office and via wi-fi using dhcp in other locations, the network settings (location & wifi on/off) would have to be changed manually on every boot. This script checks if an ethernet cable is connected and selects the matching locations automatically. Screen resolution (as user, on boot)I use an external monitor in the office and (due to a bug) it gets reset to its default resolution on every reconnect of my MacBook Pro. This script only needs user privileges and uses display manager to check the desired resolution and applies it, if necessary. Run commands at login or logout (as root)macOS provides a possibility to add a script that is run at login or logout. This section contains the scripts to install them. Feel free to adjust them to your needs. In this version the logout script cleans some caches on a regular basis. 10 DockThis script completely cleans the dock and adds new entries including apps, spacer, folders or recent applications/documents to the dock. For folders and recent entries, it includes options for the icon size (grid only) and the type to be used (automatic, stack, grid or list). It can be run with profiles - to be easily usable on multiple macs - or standalone. More information can be found in the comments inside the script and in the example profile. To run the script with a profile, duplicate the example profile and name it 11a System and app PreferencesThese are the main scripts described in the first section of this readme. They make it possible to adjust almost all of the macOS System Preferences and Apple Applications that are installed with the OS by default. It’s important to start with 11a. Otherwise, some scripts of this section will not work, as it sets certain permissions for apps that are needed afterwards. Unsolved PreferencesThe following preferences are not yet configurable with the script. Any help to add the functionality is appreciated.
12 LicensesAll bought third party apps have to get their licenses enabled after a clean install. A few can be done by restoring the correct files with the restore script, but unfortunately this is not working for all apps. This is a checklist of licenses to be restored manually. 13 Apple Mail and AccountsIn 10.11 apple moved all remaining internet accounts from
According to the version of macOS and Mail the script resets/deletes the index files to force Mail to reindex all mailboxes on its next run. 14 SambamacOS gives the user the possibility to set some options and preferences for its implemented samba client. These options are documented in
To make use of these options the script creates the configuration file
For the fastest and most reliable connection in the current version it
15 FinalizationsDespite all the automation, not everything in the process can be done by scripts yet. These files (for Apple apps and System Preferences) just give me a checklist of all preferences to be set manually. Every help to make this list shorter and add the settings to a script is welcome. Additionally, there are two more scripts:
At the end of every clean installation there are a few steps that take some cpu power and time before the mac is completely ready and usable at full speed, e.g. indexing emails after restore, full system virus scan, etc. These steps are documented in a checklist. 16 Seed update configurationThere are a lot of beta and developer seed users of macOS out there. As I am a public beta user, too, I use macOS beta on a second partition for testing. This manual tells you how to set/switch the update catalog. DisclaimerI am not responsible for any problems, damages, data loss or data corruption that may occur due to using any of this. Most of the commands are tested, but some might not be. There is always the chance that some things changed after the last usage/testing. So, use everything here completely at your own risk. Do some research if you have any concerns about commands or procedures that are included in any of the files BEFORE using them. CreditsThanks to everyone I got information from and that I forgot to credit. If someone feels left out just write me and I´ll add the credit. Thanks to all developers and users that share their knowledge and provide so much (free) high quality software that is used in many of these scripts. This would not be possible without all of their efforts. Last but not least thanks to Apple for developing an extraordinary operating system in macOS. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论