├── .gitignore ├── .travis.yml ├── LICENSE ├── Readme.md ├── banner.sh ├── install.sh ├── macstrap.sh ├── test └── prepare-build.sh ├── utils.sh └── version.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: osx 2 | osx_image: xcode12u 3 | install: 4 | - chmod a+x install.sh 5 | - ./install.sh https://github.com/guylabs/macstrap-config.git 6 | script: ./test/prepare-build.sh 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright Guy Brand 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/guylabs/macstrap.svg?branch=master)](https://travis-ci.org/guylabs/macstrap) 2 | 3 | # macstrap 4 | 5 | > Set up your macOS from scratch. 6 | 7 | macstrap is a command line tool to simplify the initial setup or the reinstallation of command line tools and GUI 8 | applications in OS X. To install and keep them up to date macstrap uses [homebrew](https://brew.sh). 9 | 10 | # Table of contents 11 | 12 | - [Requirements](#requirements) 13 | - [Installation and update](#installation-and-update) 14 | - [Configuration](#configuration) 15 | - [Default configuration](#default-configuration) 16 | - [Custom configuration](#custom-configuration) 17 | - [Migrating the configuration](#migrating-the-configuration) 18 | - [Commands](#commands) 19 | - [`install`](#install) 20 | - [`update`](#update) 21 | - [`update macstrap`](#update-macstrap) 22 | - [Acknowledgements](#acknowledgements) 23 | - [License](#license) 24 | 25 | ## Requirements 26 | 27 | macstrap has been tested on OS X 10.13+ and therefore this is needed as requirement. It is possible that it 28 | also works with earlier versions of OS X but this is not supported. 29 | 30 | ## Installation and update 31 | 32 | First read the [Configuration](#configuration) section as it is important how you want to configure macstrap. Also have 33 | a look at the [Migrating the configuration](#migrating-the-configuration) section before you update such that everything 34 | is still working properly with the new version of macstrap. After that you can install or update macstrap by executing the following line. 35 | 36 | ```shell 37 | mkdir -p /tmp/macstrap && cd /tmp/macstrap && curl -L https://github.com/guylabs/macstrap/archive/master.tar.gz | tar zx --strip 1 && bash ./install.sh && rm -rf /tmp/macstrap && cd ~ 38 | ``` 39 | 40 | This will install macstrap to the `/usr/local/lib` folder and create proper symlinks in the `/usr/local/bin` folder such 41 | that you are easily able to execute the `macstrap` command from the command line. It will also install the following required 42 | applications: 43 | 44 | * The OS X command line tools which macstrap needs for Git. 45 | * [homebrew](https://brew.sh) to install the command line tools. 46 | 47 | When you are asked to select how to configure macstrap choose the option you prefer, either the [default configuration](#default-configuration) 48 | or a [custom configuration](#custom-configuration). 49 | 50 | If you already have macstrap installed the install script will replace the old version and keep your configurations. 51 | 52 | When done execute `macstrap install` to install the configuration set above. 53 | 54 | ## Configuration 55 | 56 | macstrap is configured with a "configuration GIT repository" to enable versioning (tagging and branching) of the configuration. 57 | While installing macstrap you will be asked how to configure macstrap and are able to select the [default configuration](#default-configuration) 58 | or a [custom configuration](#custom-configuration). 59 | 60 | Have a look at the following sections to see what the default configuration contains and how to create a custom configuration. 61 | 62 | ### Default configuration 63 | 64 | The default macstrap configuration resides in the [`macstrap-config`](https://github.com/guylabs/macstrap-config) GIT repository. 65 | This repository is built up with the needed structure and contains all required default scripts and configurations. 66 | 67 | Please have a look at the [`macstrap.cfg`](https://github.com/guylabs/macstrap-config/blob/master/macstrap.cfg) to see which apps, 68 | command line tools etc. will be installed if you choose the default configuration. 69 | 70 | ### Custom configuration 71 | 72 | If you want to create a custom configuration please follow these steps: 73 | 74 | 1. Fork the [`macstrap-config`](https://github.com/guylabs/macstrap-config) repository as this also serves as template configuration repository. 75 | 2. Checkout the `README.md` files in each folder to see how to customize your configuration and have a look at the default scripts how they are built up. 76 | 3. When you finished the customizations then please commit and push the changes to your repository. 77 | 4. When you now install macstrap then please choose to select your own GIT repository and then point to the HTTPS clone URL of your customized configuration repository. 78 | 79 | ### Migrating the configuration 80 | 81 | When you upgrade to a newer version of macstrap then please check the changes done in the default [`macstrap-config`](https://github.com/guylabs/macstrap-config) GIT repository 82 | and adapt it with your version. You can easily compare the two repositories as you did a fork of the default one. This way you can easily merge the changes and update 83 | your custom repository. 84 | 85 | ## Commands 86 | 87 | macstrap offers several commands which are used to install or update the system. The following sections describe all available commands. 88 | 89 | ### `install` 90 | 91 | This command will execute the [`install.sh`](https://github.com/guylabs/macstrap-config/blob/master/commands/install.sh) of the defined configuration repository. 92 | In the default configuration it will install all tools and apps which are defined in the [`macstrap-config`](https://github.com/guylabs/macstrap-config) repository. 93 | 94 | ### `update` 95 | 96 | This command will execute the [`update.sh`](https://github.com/guylabs/macstrap-config/blob/master/commands/update.sh) of the defined configuration repository. 97 | In the default configuration it will update all tools and apps to the latest available version with the help of [homebrew](https://brew.sh). It also schedules 98 | the OSX updates of OSX specific software. 99 | 100 | ### `update-macstrap` 101 | 102 | This command will download the newest master version of macstrap and execute the `install.sh` script to update macstrap. 103 | 104 | # Acknowledgements 105 | 106 | macstrap itself is a fork of the [dots](https://github.com/matthewmueller/dots) project which has the base functionality 107 | to install and update the command line tools and the GUI applications. So please also have a look at this project if you 108 | also need a similar functionality for Ubuntu. At this point I want to thank Matthew for his nice work. 109 | 110 | # License 111 | 112 | macstrap is available under the [MIT license](https://github.com/guylabs/macstrap/blob/master/LICENSE). 113 | 114 | © Matthew Mueller - Forked project (https://github.com/matthewmueller/dots) 115 | 116 | © Modifications by Guy Brand 117 | -------------------------------------------------------------------------------- /banner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | printf "\033[1;34m _ \n" 5 | printf "\033[1;34m | | \n" 6 | printf "\033[1;34m _ __ ___ __ _ ___ ___| |_ _ __ __ _ _ __ \n" 7 | printf "\033[1;34m| '_ \` _ \ / _\` |/ __/ __| __| '__/ _\` | '_ \ \n" 8 | printf "\033[1;34m| | | | | | (_| | (__\__ \ |_| | | (_| | |_) |\n" 9 | printf "\033[1;34m|_| |_| |_|\__,_|\___|___/\__|_| \__,_| .__/ \n" 10 | printf "\033[1;34m \033[0;33mv %s\033[1;34m | | \n" "$version" 11 | printf "\033[1;34m |_| \n" 12 | printf "\033[0m\n" 13 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | . version.sh 4 | . utils.sh 5 | 6 | # Echo banner 7 | . banner.sh 8 | 9 | echo 10 | echo "####################################" 11 | echo "# Installing/updating macstrap ... #" 12 | echo "####################################" 13 | echo 14 | 15 | defaultConfigGitRepositoryUrl="https://github.com/guylabs/macstrap-config.git" 16 | 17 | # Set the paths 18 | dirname=$(pwd) 19 | lib="/usr/local/lib" 20 | bin="/usr/local/bin" 21 | conf="$HOME/.macstrap" 22 | 23 | # Create directories in case they aren't already there 24 | printf "We need sudo rights to change the owner of the \033[1m/usr/local\033[0m folder to \033[1m%s:admin\033[0m to create the \033[1m%s\033[0m and \033[1m%s\033[0m directories.\n" "$(whoami)" "$lib" "$bin" 25 | echo 26 | sudo mkdir -p $lib 27 | sudo mkdir -p $bin 28 | sudo chown -R "$(whoami)" /usr/local/* 29 | 30 | echo 31 | echo "Checking if homebrew is installed and up to date ..." 32 | echo 33 | 34 | # Check for homebrew 35 | if test ! "$(hash brew)"; then 36 | echo "Installing homebrew ..." 37 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 38 | 39 | if isArmArchitecture; then 40 | eval "$(/opt/homebrew/bin/brew shellenv)" 41 | else 42 | eval "$(brew --prefix)/bin/brew shellenv" 43 | fi 44 | else 45 | echo "Updating homebrew ..." 46 | brew update 47 | fi 48 | 49 | # Remove existing macstrap if it exists 50 | if [ -d "$lib/${PWD##*/}" ]; then 51 | rm -rf "${lib:?}/${PWD##*/}" 52 | fi 53 | 54 | # Copy the macstrap to the lib folder 55 | cp -R "$dirname" "$lib/" 56 | echo 57 | printf "Copied \033[1m%s\033[0m to \033[1m%s\033[0m\n" "$dirname" "$lib" 58 | 59 | # Remove existing bin if it exists 60 | if [ -L "$bin/macstrap" ]; then 61 | rm -f "$bin/macstrap" 62 | fi 63 | 64 | # Symlink macstrap 65 | ln -s "$lib/macstrap/macstrap.sh" "$bin/macstrap" 66 | printf "Symlinked \033[1m%s/macstrap\033[0m to \033[1m%s/macstrap/macstrap.sh\033[0m\n" "$bin" "$lib" 67 | 68 | # Setup the configuration if not already existent 69 | if [ ! -e "$conf/macstrap.cfg" ]; then 70 | 71 | # create the temporary directory to clone or copy the configuration 72 | mkdir -p "$conf" 73 | cd "$conf" 74 | 75 | if [ -z "$1" ]; then 76 | 77 | echo 78 | printf "\033[1mPlease provide the configuration for macstrap\033[0m:\n" 79 | echo " The configuration of macstrap is based on a GIT repository. You can enter a custom HTTPS URL which points to a GIT repository," 80 | echo " or do not provide a URL and the default GIT repository is used instead: $defaultConfigGitRepositoryUrl" 81 | echo 82 | echo " When using a secured Git repository and you configured 2 factor authentication, use the given access token as password when requested to enter the credentials." 83 | echo 84 | printf "Configuration GIT repository HTTPS URL: " 85 | echo 86 | 87 | read -r customGitUrl 88 | 89 | if [ -z "$customGitUrl" ]; then 90 | printf "Using default GIT repository: $defaultConfigGitRepositoryUrl" 91 | echo 92 | git clone "$defaultConfigGitRepositoryUrl" "$conf" 93 | else 94 | git clone "$customGitUrl" "$conf" 95 | fi 96 | else 97 | printf "Unattended installation with configuration GIT repository: \033[1m%s\033[0m\n" "$1" 98 | git clone "$1" "$conf" 99 | fi 100 | else 101 | printf "Configuration folder \033[1m%s\033[0m and \033[1m%s/macstrap.cfg\033[0m file already exists.\n" "$conf" "$conf" 102 | fi 103 | 104 | # if macstrap was installed with the base installation, then delete the extracted /tmp/macstrap folder again 105 | if [ -e "/tmp/macstrap" ]; then 106 | cd ~/ 107 | rm -rf "/tmp/macstrap" 108 | echo 109 | echo "Removed installation files" 110 | fi 111 | 112 | echo 113 | printf "\033[1;34m##########################################\n" 114 | printf "\033[1;34m# macstrap \033[0;33mv%s\033[1;34m successfully installed #\n" "$version" 115 | printf "\033[1;34m##########################################\033[0m\n" 116 | -------------------------------------------------------------------------------- /macstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # macstrap main 5 | main() { 6 | 7 | # load the version 8 | macstrapInstallFolder="$(dirname "$(realpath "$0")")" 9 | . "$macstrapInstallFolder/version.sh" 10 | . "$macstrapInstallFolder/utils.sh" 11 | 12 | # global variables 13 | export macstrapVersion="$version" 14 | export macstrapConfigFolder="$HOME/.macstrap" 15 | export macstrapConfigFile="$macstrapConfigFolder/macstrap.cfg" 16 | 17 | if [ $# -eq 0 ]; then 18 | # if no argument is present show the usage 19 | usage 20 | exit 21 | else 22 | # run command 23 | case $1 in 24 | -v | --version ) 25 | echo "macstrap $version" 26 | exit 27 | ;; 28 | -h | --help ) 29 | usage 30 | exit 31 | ;; 32 | install ) 33 | executeCommand "install" 34 | exit 35 | ;; 36 | update ) 37 | executeCommand "update" 38 | exit 39 | ;; 40 | "update-macstrap" ) 41 | updatemacstrap 42 | exit 43 | ;; 44 | *) 45 | usage 46 | exit 47 | ;; 48 | esac 49 | fi 50 | } 51 | 52 | # usage info 53 | usage() { 54 | . "$macstrapInstallFolder/banner.sh" 55 | 56 | cat <