├── Ansible
├── README.md
├── Extension Attributes
│ ├── EA_HTTP_Proxy.sh
│ ├── EA_PAC_Proxy.sh
│ ├── EA_DNS_Settings.sh
│ ├── EA_HTTPS_Proxy.sh
│ ├── EA_Hostname.sh
│ └── EA_Swift_Lint_Version.sh
├── CreateUser.sh
└── CreateMiniData.sh
├── .gitignore
├── Homebrew
├── Extension Attributes
│ ├── README.md
│ ├── XcodeCLI_EA.sh
│ └── Homebrew_EA.sh
├── README.md
├── InstallHomebrewPackages.sh
└── InstallHomebrew.sh
├── README.md
├── Python
├── README.md
└── installPythonPackages.py
├── Ruby
├── README.md
└── InstallRubyGems.sh
└── Xcode
├── README.md
└── InstallXcode.sh
/Ansible/README.md:
--------------------------------------------------------------------------------
1 | Coming soon.
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | */.DS_Store
--------------------------------------------------------------------------------
/Homebrew/Extension Attributes/README.md:
--------------------------------------------------------------------------------
1 | # Extension Attributes
2 |
3 | - `Homebrew_EA.sh`
4 | - Displays the Homebrew version installed
5 | - `XcodeCLI_CA.sh`
6 | - Displays the Xcode Command Line Tools version installed
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WCS
2 |
3 | ### Script List
4 | - **Xcode**
5 | - `InstallXcode.sh`
6 | - **Homebrew**
7 | - `InstallHomebrew.sh`
8 | - `InstallHomebrewPackages.sh`
9 | - **Extension Attributes**
10 | - `Homebrew_EA.sh`
11 | - `XcodeCLI_EA.sh`
12 | - **Ruby**
13 | - `InstallRubyGems.sh`
14 | - **Python**
15 | - `InstallPythonPackages.py`
16 |
17 |
--------------------------------------------------------------------------------
/Python/README.md:
--------------------------------------------------------------------------------
1 | # installPythonPackages.py
2 |
3 | An easy way to install python3 packages as the current logged in user on macOS systems via Jamf Pro.
4 |
5 | ----
6 | ## Requirements
7 | - Python3 *(Tested with 3.9.13)*
8 | - List of packages as a Comma Seperated List in Script Parameter #4
9 |
10 | ----
11 | ## Setup
12 | 1. Add script to Jamf Pro Server
13 | 1. Create a new policy and add the `installPythonPackages.py` script
14 | 1. Enter the list of python3 packages to install in Script Parameter #4 as a Comma Seperated List
15 | - **Example:** `requests, virtualenv, slack_sdk, tinydb`
16 |
17 | > Be sure to set the trigger and scope correctly. This will vary based on how you want to deploy it.
18 |
19 | ----
20 | ## Logging
21 | This script creates a log file at `/private/var/log/installPythonPackages.log`
--------------------------------------------------------------------------------
/Ruby/README.md:
--------------------------------------------------------------------------------
1 | # `InstallRubyGems.sh`
2 |
3 | An easy way to install Ruby Gems on macOS system via Jamf Pro.
4 |
5 | ----
6 | ## Requirements
7 | - [swiftDialog](https://github.com/bartreardon/swiftDialog) installed.
8 | - **Note:** This script will download and install swiftDialog if it's not found.
9 |
10 | ----
11 | ## Setup
12 | 1. Add script to Jamf Pro Server
13 | 1. Create a new policy and add the `InstallRubyGems.sh` script
14 | 1. Enter the list of Ruby Gems to install in Script Parameter #4 as a Comma Seperated List
15 | - **Example:** `fastlane,cocoapods,slather,xcpretty,xcode-install,bundler,jazzy`
16 |
17 | > Be sure to set the trigger and scope correctly. This will vary based on how you want to deploy it.
18 |
19 | ----
20 | ## Logging
21 | This script creates a logfile at `/private/var/log/installRubyGemsLog.log`
--------------------------------------------------------------------------------
/Xcode/README.md:
--------------------------------------------------------------------------------
1 | # `installXcode.sh`
2 |
3 | A quicker way to install Xcode on macOS systems via Jamf Pro.
4 |
5 | ----
6 | ## Requirements
7 | - Xcode Package uploaded to Jamf Pro
8 | - *Requires a free Developer Account for [developer.apple.com](https://developer.apple.com)*
9 | - A policy in Jamf Pro to install XcodeCLI with a custom trigger
10 | - [swiftDialog](https://github.com/bartreardon/swiftDialog) installed.
11 | - **Note:** This script will download and install swiftDialog if it's not found.
12 | - [unxip](https://github.com/saagarjha/unxip)
13 | - This is used to expand `Xcode.xip` faster than the default method
14 |
15 | > Note: Before uploading Xcode to Jamf Pro, you will need to add `.pkg` to the end of `Xcode.xip`. (Example: `Xcode.xip.pkg`)
16 |
17 | ----
18 | ## Setup
19 | 1. Create a new policy to **cache** Xcode with a custom trigger *(This will allow you to cache Xcode ahead of time to help speed up the install process.)*
20 | 1. Add script to Jamf Pro Server and customize the variables in the table listed below
21 | 1. Enter the Version of Xcode you are deploying *(Example: 13.4)* in Script Parameter #4
22 | 1. Enter the custom trigger for the **cache** Xcode Policy in Script Parameter #5
23 |
24 | **Variable Name** | **Line Number** | **Usage**
25 | ----------------- | --------------- | ---------
26 | `XCODE_XIP_PATH` | 12 | Location to UNXIP Xcode to
27 | `UNXIP` | 13 | Location of `unxip` install
28 | `UTILITYDIR` | 14 | Location of the directory you put resource files in.
29 |
30 | > Be sure to set the trigger and scope correctly. This will vary based on how you want to deploy it.
31 |
32 | ----
33 | ## Logging
34 | This script creates a log file at `/private/var/log/InstallXcode.log`
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_HTTP_Proxy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the HTTP proxy the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | httpproxy=$(networksetup -getwebproxy Ethernet | xargs)
38 |
39 | if [[ ! -z "$httpproxy" ]]; then
40 | echo "$httpproxy"
41 | else
42 | echo "Missing"
43 | fi
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_PAC_Proxy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the .pac proxy the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | pacproxy=$(networksetup -getautoproxyurl Ethernet | xargs)
38 |
39 | if [[ ! -z "$pacproxy" ]]; then
40 | echo "$pacproxy"
41 | else
42 | echo "Missing"
43 | fi
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_DNS_Settings.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the DNS settings the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | dns=$(cat /etc/resolv.conf | grep ^nameserver | awk '{print $2}'| xargs)
38 |
39 | if [[ ! -z "$dns" ]]; then
40 | echo "$dns"
41 | else
42 | echo "Missing"
43 | fi
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_HTTPS_Proxy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the HTTPS proxy the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | httpsproxy=$(networksetup -getsecurewebproxy Ethernet | xargs)
38 |
39 | if [[ ! -z "$httpsproxy" ]]; then
40 | echo "$httpsproxy"
41 | else
42 | echo "Missing"
43 | fi
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_Hostname.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the last part of the hostname the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | getHostname=$(host `/bin/hostname` | sed 's/\([^ ]*\)\ .*/\1/')
38 |
39 | if [[ ! -z "$getHostname" ]]; then
40 | echo "$getHostname"
41 | else
42 | echo "Missing"
43 | fi
44 |
--------------------------------------------------------------------------------
/Ansible/Extension Attributes/EA_Swift_Lint_Version.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 08/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This EA will capture the swift lint version the system is using.
34 | #
35 | ####################################################################################################
36 |
37 | swiftlint=$(/usr/local/bin/brew list swiftlint --versions | sed 's/swiftlint //')
38 |
39 | if [[ ! -z "$swiftlint" ]]; then
40 | echo "$swiftlint"
41 | else
42 | echo "Missing"
43 | fi
--------------------------------------------------------------------------------
/Homebrew/README.md:
--------------------------------------------------------------------------------
1 | # Homebrew
2 |
3 | > This repository also contains Extension Attributes that can be used to help scope and return the Homebrew and Xcode Command Line Tools versions. Those can be found within the **Extension Attributes** folder.
4 |
5 | ## `InstallHomebrew.sh`
6 |
7 | An easy way to install Homebrew on macOS systems via Jamf Pro.
8 |
9 | ----
10 | ## Requirements
11 | - Xcode Command Line Tools Package uploaded to Jamf Pro
12 | - *Requires a free Developer Account for [developer.apple.com](https://developer.apple.com)*
13 | - A policy in Jamf Pro to install XcodeCLI with a custom trigger
14 | - [swiftDialog](https://github.com/bartreardon/swiftDialog) installed.
15 | - **Note:** This script will download and install swiftDialog if it's not found.
16 |
17 | ----
18 | ## Setup
19 | 1. Add script to Jamf Pro Server
20 | 1. Create a new policy and add the `InstallHomebrew.sh` script
21 | 1. Enter the custom trigger for the Install Xcode Command Line Tools Policy in Script Parameter #4
22 |
23 | > Be sure to set the trigger and scope correctly. This will vary based on how you want to deploy it.
24 |
25 | ----
26 | ## Logging
27 | This script creates the following log files:
28 | - `/private/var/log/InstallHomebrew.log`
29 | - This is the logfile for the `InstallHomebrew` script.
30 | - `/private/var/log/Homebrew.log`
31 | - This is the logfile for when the script updates Homebrew.
32 | - `/Users/Shared/xcodecliversion`
33 | - This is the logfile that contains the Xcode Command Line Tools version
34 |
35 | ----
36 |
37 | ## `InstallHomebrewPackages.sh`
38 |
39 | An easy way to install Homebrew Packages on macOS systems via Jamf Pro
40 |
41 | ----
42 | ## Requirements
43 | - [swiftDialog](https://github.com/bartreardon/swiftDialog) installed.
44 | - **Note:** This script will download and install swiftDialog if it's not found.
45 |
46 | ----
47 | ## Setup
48 | 1. Add script to Jamf Pro Server
49 | 1. Create a new policy and add the `InstallHomebrewPackages.sh` script
50 | 1. Enter the list of Homebrew Packages to install in Script Parameter #4 as a Comma Seperated List
51 | - **Example:** `jq,wget,git,python,mint,carthage`
52 |
53 | > Be sure to set the trigger and scope correctly. This will vary based on how you want to deploy it.
54 |
55 | ----
56 | ## Logging
57 | This script creates the following log files:
58 | - `/private/var/log/InstallHomebrewPackages.log`
59 | - This is the logfile for the `InstallHomebrewPackages` script.
60 | - `/private/var/log/Homebrew.log`
61 | - This is the logfile for when the script updates Homebrew.
--------------------------------------------------------------------------------
/Homebrew/Extension Attributes/XcodeCLI_EA.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 06/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This is an Extension Attribute that will display the version of Xcode Command Line Tools
34 | # if it's installed. If not, it will return "Not Installed".
35 | #
36 | # Usage: Extension Attribute in Jamf Pro
37 | #
38 | ####################################################################################################
39 |
40 | xcodeCLIVersion=$(cat /Users/Shared/xcodecliversion)
41 |
42 | if [[ ! -z "$xcodeCLIVersion" ]]; then
43 | echo "$xcodeCLIVersion"
44 | else
45 | ## If Xcode CLI is not installed, this file will be empty, so lets change it to "Not Installed" so it's clear when looking at the EA
46 | echo "Not Installed"
47 | fi
--------------------------------------------------------------------------------
/Homebrew/Extension Attributes/Homebrew_EA.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 06/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This is an Extension Attribute that will display the version of Homebrew
34 | # if it's installed. If not, it will return "Not Installed".
35 | #
36 | # Usage: Extension Attribute in Jamf Pro
37 | #
38 | ####################################################################################################
39 |
40 | ################# VARIABLES ######################
41 | ## currentUser: Grabs the username of the current logged in user **DO NOT CHANGE**
42 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }')
43 | ###################################################
44 |
45 | ## Lets see what architecture the system is..
46 | macOSArch=$(/usr/bin/uname -m)
47 |
48 | if [[ "$macOSArch" == "x86_64" ]]; then
49 | homebrewPath="/usr/local/bin/brew"
50 | elif [[ "$macOSArch" == "arm64" ]]; then
51 | homebrewPath="/opt/homebrew/bin/brew"
52 | fi
53 |
54 | homebrewVersion=$(su -l $currentUser -c "$homebrewPath -v")
55 |
56 | if [[ ! -z "$homebrewVersion" ]]; then
57 | echo "$homebrewVersion"
58 | else
59 | ## If Homebrew is not installed, this file will be empty, so lets change it to "Not Installed" so it's clear when looking at the EA
60 | echo "Not Installed"
61 | fi
--------------------------------------------------------------------------------
/Python/installPythonPackages.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Github: https://github.com/therealmacjeezy
31 | # Last Modified: 06/09/2022
32 | # Version: 0.2
33 | #
34 | # Description: This script will update pip3 then bulk install pip3 packages using
35 | # Jamf Pro Script Parameters
36 | #
37 | ####################################################################################################
38 |
39 | import logging, sys, subprocess, os
40 |
41 | ################# VARIABLES ######################
42 | findUser = os.popen('stat -f %Su /dev/console')
43 | currentUser = findUser.read()
44 | currentUser = currentUser.strip()
45 | ###################################################
46 |
47 | logging.basicConfig(
48 | ## Logging Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
49 | ## Usage: logging.LEVEL('message')
50 | filename = '/private/var/log/installPythonPackages.log',
51 | level = logging.DEBUG,
52 | format = '>>[%(filename)s] :: %(levelname)s [%(asctime)s] :: %(message)s'
53 | )
54 |
55 | logging.info(f'Starting script as user {currentUser}')
56 |
57 | ## Check to see if Script Parameter #4 contains the list of python3 packages to install, if not exit.
58 | if sys.argv[4]:
59 | logging.info('Found python3 packages to install.')
60 | packages = sys.argv[4]
61 | packages = packages.split(',')
62 | else:
63 | logging.error('Missing list of python3 packages to install. Check Script Parameter #4.')
64 | sys.exit(1)
65 |
66 | ## Function to install the python3 package
67 | def install(package):
68 | try:
69 | # __import__(package)
70 | os.system(f"su -l {currentUser} -c \"/usr/local/bin/python3 -c 'import {package}'\"")
71 | logging.info(f'{package} is already installed! Lets make sure it is up to date!')
72 | try:
73 | # subprocess.check_call([sys.executable, "-m", "pip", "-q", "-q", "install", "--upgrade", package])
74 | subprocess.run(["su", "-l", currentUser, "-c", f"/usr/local/bin/python3 -m pip -q -q install --upgrade {package} --user"])
75 | logging.info(f'{package} is up to date.')
76 | except Exception as errorMessage:
77 | logging.error(errorMessage)
78 | except:
79 | logging.info(f'Looks like {package} isnt installed..installing now')
80 | try:
81 | subprocess.run(["su", "-l", currentUser, "-c", f"/usr/local/bin/python3 -m pip -q -q install {package} --user"])
82 | # subprocess.check_call([sys.executable, "-m", "pip", "-q", "-q", "install", package])
83 | logging.info(f'Successfully installed {package}!')
84 | except Exception as errorMessage:
85 | logging.error(errorMessage)
86 |
87 |
88 |
89 | ## Check to see if pip3 is up to date and if not, install the latest version
90 | try:
91 | logging.info('Making sure pip3 is up to date.')
92 | # subprocess.check_call([sys.executable, "-m", "pip", "-q", "-q", "install", "--upgrade", "pip"])
93 | subprocess.run(["su", "-l", currentUser, "-c", f"/usr/local/bin/python3 -m pip -q -q install --upgrade pip"])
94 | logging.info('pip3 update check complete.')
95 | except Exception as errorMessage:
96 | logging.error(errorMessage)
97 |
98 | ## Start the package installs
99 | for p in packages:
100 | p = p.strip()
101 | logging.info(f'Checking to see if {p} is installed..')
102 | install(p)
103 |
104 |
--------------------------------------------------------------------------------
/Ruby/InstallRubyGems.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 06/07/2022
31 | # Version: 0.2
32 | #
33 | # Description: This script will install Ruby Gems on macOS systems via Jamf Pro
34 | #
35 | ####################################################################################################
36 |
37 | ################# VARIABLES ######################
38 | ## rubyGems: The list of packages you want to install via Ruby, seperated by commas **REQUIRED**
39 | rubyGems="$4"
40 | ## currentUser: Grabs the username of the current logged in user **DO NOT CHANGE**
41 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }')
42 | ## installRubyGemsLog: Location of the installRubyGems script log **DO NOT CHANGE**
43 | installRubyGemsLog="/private/var/log/installRubyGemsLog.log"
44 | ## currentTime: Gets the time for the log **DO NOT CHANGE**
45 | currentTime=$(date +%H:%M)
46 |
47 | ### swiftDialog Variables
48 | dialogLogFile="/var/tmp/dialog.log"
49 | dialogPath="/usr/local/bin/dialog"
50 | dialogTitle="Ruby Gem Installs"
51 | dialogIcon="https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Ruby_logo.svg/128px-Ruby_logo.svg.png"
52 | declare -a theSteps
53 | theSteps=(
54 | "\"Getting List of Ruby Gems\""
55 | )
56 |
57 | for s in ${rubyGems//,/ }; do
58 | echo "$s"
59 | theSteps+=("\"$s\"")
60 | done
61 |
62 | theStepsLength="${#theSteps[@]}"
63 | currentStep=0
64 | dialogConfig=(
65 | "--title \"$dialogTitle\""
66 | "--icon \"$dialogIcon\""
67 | "--position topleft"
68 | "--message \" \""
69 | "--messagefont \"size=16\""
70 | # "--small"
71 | "--ontop"
72 | "--moveable"
73 | # "--position centre"
74 | "${theSteps[@]/#/--listitem }"
75 | )
76 | ###################################################
77 |
78 | ## Logging Function
79 | log_it () {
80 | if [[ ! -z "$1" && -z "$2" ]]; then
81 | logEvent="INFO"
82 | logMessage="$1"
83 | elif [[ "$1" == "warning" ]]; then
84 | logEvent="WARN"
85 | logMessage="$2"
86 | elif [[ "$1" == "success" ]]; then
87 | logEvent="SUCCESS"
88 | logMessage="$2"
89 | elif [[ "$1" == "error" ]]; then
90 | logEvent="ERROR"
91 | logMessage="$2"
92 | fi
93 |
94 | if [[ ! -z "$logEvent" ]]; then
95 | echo ">>[installRubyGemsLog.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage"
96 | echo ">>[installRubyGemsLog.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage" >> "$installRubyGemsLog"
97 | fi
98 | }
99 |
100 | update_dialog () {
101 | log_it "DIALOG: $1"
102 | echo "$1" >> "$dialogLogFile"
103 | }
104 |
105 | finish_dialog () {
106 | update_dialog "progresstext: Ruby Gem Installs Complete"
107 | sleep 1
108 | update_dialog "quit:"
109 | exit 0
110 | }
111 |
112 | if [[ ! -f "$dialogPath" ]]; then
113 | log_it "swiftDialog not installed"
114 | dialogDownload=$( curl -sL https://api.github.com/repos/bartreardon/swiftDialog/releases/latest )
115 | dialogURL=$(get_json_value "$dialogDownload" 'assets[0].browser_dialogURL')
116 | curl -L --output "dialog.pkg" --create-dirs --output-dir "/var/tmp" "$dialogURL"
117 | installer -pkg "/var/tmp/dialog.pkg" -target /
118 | fi
119 |
120 | rm "$dialogLogFile"
121 | eval "$dialogPath" "${dialogConfig[*]}" & sleep 1
122 |
123 | for (( i=0; i&1 | tee -a "$installRubyGemsLog"
143 | checkInstall=$(which $p | grep "not found")
144 | if [[ -z "$checkInstall" ]]; then
145 | log_it "success" "$p was installed successfully."
146 | update_dialog "listitem: title: $p, status: success"
147 | else
148 | log_it "error" "$p was unable to be installed. View installRubyGemsLog.log for details."
149 | update_dialog "listitem: title: $p, status: error"
150 | fi
151 | done
152 | }
153 |
154 | install_gems
155 | finish_dialog
--------------------------------------------------------------------------------
/Xcode/InstallXcode.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##############
4 | # Original Version from https://smithjw.me/2022/05/20/Installing-Xcode-xip/
5 | # Modified by Josh Harvey on 06/01/2022
6 |
7 |
8 | XCODE_VERSION="$4"
9 | XCODE_TRIGGER="$5"
10 | XCODE_NAME="Xcode_${XCODE_VERSION}"
11 | XCODE_XIP_CACHE="/Library/Application Support/JAMF/Waiting Room/${XCODE_NAME}.xip.pkg"
12 | XCODE_XIP_PATH="/Library/Mooncheese/${XCODE_NAME}.xip"
13 | UNXIP="/Library/Mooncheese/Tools/unxip"
14 | UTILITYDIR="/Library/Mooncheese"
15 |
16 | LOG_FOLDER="/private/var/log"
17 | LOG_NAME="InstallXcode.log"
18 | JAMF_BINARY="/usr/local/bin/jamf"
19 | DIALOG_APP="/usr/local/bin/dialog"
20 | DIALOG_COMMAND_FILE="/var/tmp/dialog.log"
21 | DIALOG_ICON="https://developer.apple.com/assets/elements/icons/xcode-12/xcode-12-256x256.png"
22 | DIALOG_INITIAL_TITLE="Installing Xcode"
23 |
24 | DIALOG_STEPS=(
25 | "\"Downloading Xcode\""
26 | "\"Unpacking Xcode\""
27 | "\"Moving Xcode into Place\""
28 | "\"Setting Permissions\""
29 | "\"Installing Xcode Packages\""
30 | )
31 | DIALOG_STEP_LENGTH="${#DIALOG_STEPS[@]}"
32 | DIALOG_STEP=0
33 |
34 | DIALOG_CMD=(
35 | "--title \"$DIALOG_INITIAL_TITLE\""
36 | "--icon \"$DIALOG_ICON\""
37 | "--position topleft"
38 | "--message \" \""
39 | "--messagefont \"size=16\""
40 | # "--small"
41 | "--ontop"
42 | "--moveable"
43 | # "--position centre"
44 | "${DIALOG_STEPS[@]/#/--listitem }"
45 | )
46 |
47 | echo_logger() {
48 | LOG_FOLDER="${LOG_FOLDER:=/private/var/log}"
49 | LOG_NAME="${LOG_NAME:=log.log}"
50 |
51 | mkdir -p $LOG_FOLDER
52 |
53 | echo -e "$(date) - $1" | tee -a $LOG_FOLDER/$LOG_NAME
54 | }
55 |
56 | dialog_update() {
57 | echo_logger "DIALOG: $1"
58 | # shellcheck disable=2001
59 | echo "$1" >> "$DIALOG_COMMAND_FILE"
60 | }
61 |
62 | dialog_finalise() {
63 | dialog_update "progresstext: Xcode Install Complete"
64 | sleep 1
65 | dialog_update "quit:"
66 | exit 0
67 | }
68 |
69 | get_json_value() {
70 | JSON="$1" osascript -l 'JavaScript' \
71 | -e 'const env = $.NSProcessInfo.processInfo.environment.objectForKey("JSON").js' \
72 | -e "JSON.parse(env).$2"
73 | }
74 |
75 | if [ ! -f "$DIALOG_APP" ]; then
76 | echo_logger "swiftDialog not installed"
77 | dialog_latest=$( curl -sL https://api.github.com/repos/bartreardon/swiftDialog/releases/latest )
78 | dialog_url=$(get_json_value "$dialog_latest" 'assets[0].browser_download_url')
79 | curl -L --output "dialog.pkg" --create-dirs --output-dir "/var/tmp" "$dialog_url"
80 | installer -pkg "/var/tmp/dialog.pkg" -target /
81 | fi
82 |
83 | rm "$DIALOG_COMMAND_FILE"
84 | eval "$DIALOG_APP" "${DIALOG_CMD[*]}" & sleep 1
85 |
86 | for (( i=0; i>[CreateUsers.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage"
68 | echo ">>[CreateUsers.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage" >> "$createUsersLog"
69 | fi
70 | }
71 |
72 | macOSArch=$(/usr/bin/uname -m)
73 |
74 | create_user () {
75 | uidGen=$(awk 'BEGIN{srand();print int(rand()*(1500-1200))+505 }')
76 |
77 | dscl . -create /Users/"$userName"
78 | dscl . -create /Users/"$userName" UserShell /bin/bash
79 | dscl . -create /Users/"$userName" UniqueID $userNameidGen
80 | dscl . -create /Users/"$userName" PrimaryGroupID 80
81 | dscl . -create /Users/"$userName" NFSHomeDirectory /Users/"$userName"
82 | dscl . -append /Groups/admin GroupMembership "$userName"
83 | cp -R /System/Library/User\ Template/English.lproj /Users/"$userName"
84 | log_it "info" "Created user account for: $userName"
85 |
86 | echo "$sshKey" > /Users/"$userName"/.ssh/authorized_keys
87 | chmod 0644 /Users/"$userName"/.ssh/authorized_keys
88 | log_it "info" "Created authorized_keys file for: $userName"
89 |
90 | echo "$userName ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/"$userName"
91 | log_it "info" "Created sudoers.d file for: $userName"
92 |
93 | /bin/cat > /Users/"$userName"/.bash_profile <<'bash_profile'
94 | # Get the aliases and functions
95 | if [ -f ~/.bashrc ]; then
96 | . ~/.bashrc
97 | fi
98 |
99 | # User specific environment and startup programs
100 | bash_profile
101 |
102 | log_it "info" "Created bash_profile for: $userName"
103 |
104 | if [[ "$macOSArch" == "x86_64" ]]; then
105 | log_it "System Architecture: Intel (64-Bit)"
106 | /bin/cat > /Users/"$userName"/.bashrc << 'bashrc'
107 | export NVM_DIR="$/usr/local/bin/.nvm"
108 |
109 | # support for UTF-8 encoding
110 | export LANG=en_US.UTF-8
111 | export LANGUAGE=en_US.UTF-8
112 | export LC_ALL=en_US.UTF-8
113 |
114 | export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"
115 | export PATH=/usr/local/bin:$PATH
116 | # brew installs python3 by default
117 | alias python=/usr/local/bin/python3
118 | alias pip=/usr/local/bin/pip3
119 | bashrc
120 | elif [[ "$macOSArch" == "arm64" ]]; then
121 | log_it "System Architecture: Apple Silicon 64-Bit"
122 | /bin/cat > /Users/"$userName"/.bashrc << 'bashrcApple'
123 | export NVM_DIR="$/usr/local/bin/.nvm"
124 |
125 | # support for UTF-8 encoding
126 | export LANG=en_US.UTF-8
127 | export LANGUAGE=en_US.UTF-8
128 | export LC_ALL=en_US.UTF-8
129 |
130 | export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home"
131 | export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH
132 | # brew installs python3 by default
133 | alias python=/opt/homebrew/bin/python3
134 | alias pip=/opt/homebrew/bin/pip3
135 | bashrcApple
136 | fi
137 | log_it "info" "Created .bashrc for: $userName"
138 | }
139 |
140 |
141 | if [[ ! -z "$4" ]]; then
142 | userName="$4"
143 | if [[ ! -z "$5" ]]; then
144 | sshKey="$5"
145 | create_user
146 | else
147 | log_it "error" "Missing public ssh key for $userName (Script Parameter #5)"
148 | fi
149 | else
150 | log_it "error" "Missing username of user to create (Script Parameter #4)"
151 | exit 1
152 | fi
--------------------------------------------------------------------------------
/Ansible/CreateMiniData.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 07/28/2022
31 | # Version: 0.1
32 | #
33 | # Description: This script will create a launchd item and place the GetMiniData.sh script locally
34 | # on the system.
35 | #
36 | ####################################################################################################
37 |
38 | ################# VARIABLES ######################
39 | ## currentUser: Grabs the username of the current logged in user **DO NOT CHANGE**
40 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }')
41 | ## createUsersLog: Location of the CreateMiniData script log **DO NOT CHANGE**
42 | createMiniData="/private/var/log/CreateMiniData.log"
43 | ## currentTime: Gets the time for the log **DO NOT CHANGE**
44 | currentTime=$(date +%H:%M)
45 |
46 | ## Logging Function
47 | log_it () {
48 | if [[ ! -z "$1" && -z "$2" ]]; then
49 | logEvent="INFO"
50 | logMessage="$1"
51 | elif [[ "$1" == "warning" ]]; then
52 | logEvent="WARN"
53 | logMessage="$2"
54 | elif [[ "$1" == "success" ]]; then
55 | logEvent="SUCCESS"
56 | logMessage="$2"
57 | elif [[ "$1" == "error" ]]; then
58 | logEvent="ERROR"
59 | logMessage="$2"
60 | fi
61 |
62 | if [[ ! -z "$logEvent" ]]; then
63 | echo ">>[CreateMiniData.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage"
64 | echo ">>[CreateMiniData.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage" >> "$createMiniData"
65 | fi
66 | }
67 |
68 | if [[ ! -z "$4" ]]; then
69 | looperInstance="$4"
70 | else
71 | log_it "error" "Missing looper instance (Script Parameter #4)"
72 | exit 1
73 | fi
74 |
75 | /bin/cat > /Users/jenkinspan/temp/get_mini_data.sh << 'get_mini_data'
76 | #!/bin/bash
77 |
78 | cd /Users/jenkinspan/temp/
79 |
80 | # Get Hostname
81 | hostname=$(scutil --get ComputerName)
82 |
83 | # Set Looper Instance
84 | looper_instance=$looperInstance
85 |
86 | # Get Serial number
87 | serial=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
88 |
89 | # Get Processor & cores
90 | processor=$(system_profiler SPHardwareDataType | awk -F':' '/Processors/ {print $2}' |xargs )
91 | cores=$(system_profiler SPHardwareDataType | awk -F':' '/Cores:/ {print $2}' | xargs )
92 |
93 | # Get RAM
94 | ram=$(system_profiler SPHardwareDataType | awk -F':' '/Memory:/ {print $2}')
95 |
96 | # Get Disk capacity
97 | disk=$(df -H | awk '/\/System\/Volumes\/Data$/ {printf("%s\n", $2)}')
98 |
99 | # OS version
100 | sw_ver=$(sw_vers -productVersion)
101 |
102 | # Get Xcode versions
103 | xcode=$(/usr/local/bin/xcversion installed | awk '{print $1}' | xargs)
104 |
105 | # Get swiftlint versions
106 | swiftlint=$(/usr/local/bin/brew list swiftlint --versions | sed 's/swiftlint //')
107 |
108 | # Get Network connection speed
109 | nw_speed=$(ifconfig en0 | grep media | sed 's/.* (\(.*\))/\1/' | awk '{ print $1}')
110 |
111 | # Get DNS servers
112 | dns=$(cat /etc/resolv.conf | grep ^nameserver | awk '{print $2}'| xargs)
113 |
114 | # Get FileVault status
115 | file_vault=$(fdesetup isactive)
116 |
117 | # Get Mini model
118 | model=$(sysctl hw.model | awk -F':' '{print $2}' | xargs)
119 |
120 | # Get http proxy
121 | httpproxy=$(networksetup -getwebproxy Ethernet | xargs)
122 |
123 | # Get https proxy
124 | httpsproxy=$(networksetup -getsecurewebproxy Ethernet | xargs)
125 |
126 | # Get .pac proxy
127 | pacproxy=$(networksetup -getautoproxyurl Ethernet | xargs)
128 |
129 | # Get Update_time
130 | update_time=$(date "+%D %T %Z")
131 |
132 | echo "{
133 | \"looper_instance\": \"$looper_instance\",
134 | \"serial\": \"$serial\",
135 | \"processor\": \"$processor x $cores\",
136 | \"ram\": \"$ram\",
137 | \"disk\": \"$disk\",
138 | \"sw_ver\": \"$sw_ver\",
139 | \"xcode\": \"$xcode\",
140 | \"swiftlint\": \"$swiftlint\",
141 | \"nw_speed\": \"$nw_speed\",
142 | \"dns\": \"$dns\",
143 | \"file_vault\": \"$file_vault\",
144 | \"model\": \"$model\",
145 | \"httpproxy\": \"$httpproxy\",
146 | \"httpsproxy\": \"$httpsproxy\",
147 | \"pacproxy\": \"$pacproxy\",
148 | \"update_time\": \"$update_time\"
149 | }" > data.json
150 |
151 | curl -X POST \
152 | http://deployer.walmart.com:80/api/$hostname \
153 | -H 'cache-control: no-cache' \
154 | -H 'content-type: application/json' \
155 | -d "@data.json"
156 | get_mini_data
157 |
158 | chmod 0755 /Users/jenkinspan/temp/get_mini_data.sh
159 | log_it "info" "Created get_mini_data.sh and set permissions to 0755"
160 |
161 | /bin/cat > /Library/LaunchDaemons/com.looper.get_mini_data.plist << 'launchd_item'
162 |
163 |
164 |
165 |
166 | Label
167 | com.looper.get-mini-data
168 | Program
169 | /Users/jenkinspan/temp/get_mini_data.sh
170 | StartInterval
171 | 3600
172 | UserName
173 | jenkinspan
174 |
175 |
176 | launchd_item
177 |
178 | chmod 0644 /Library/LaunchDaemons/com.looper.get_mini_data.plist
179 | log_it "info" "Created get_mini_data.plist and set permissions to 0644"
180 |
181 | launchctl load /Library/LaunchDaemons/com.looper.get_mini_data.plist
182 | log_it "info" "Loaded get_mini_data.plist"
--------------------------------------------------------------------------------
/Homebrew/InstallHomebrewPackages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 06/02/2022
31 | # Version: 0.1
32 | #
33 | # Description: This script will verify that Homebrew is installed and then installs any Homebrew
34 | # Packages that you need for your environment.
35 | #
36 | ####################################################################################################
37 |
38 | ################# VARIABLES ######################
39 | ## homebrewPackages: The list of packages you want to install via Homebrew, seperated by commas **REQUIRED**
40 | homebrewPackages="$4"
41 | ## currentUser: Grabs the username of the current logged in user **DO NOT CHANGE**
42 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }')
43 | ## InstallHomebrewPackages: Location of the InstallHomebrewPackages script log **DO NOT CHANGE**
44 | InstallHomebrewPackages="/private/var/log/InstallHomebrewPackages.log"
45 | ## homebrewLog: Location of the Homebrew log **DO NOT CHANGE**
46 | homebrewLog="/private/var/log/Homebrew.log"
47 | ## currentTime: Gets the time for the log **DO NOT CHANGE**
48 | currentTime=$(date +%H:%M)
49 |
50 | ### swiftDialog Variables
51 | dialogLogFile="/var/tmp/dialog.log"
52 | dialogPath="/usr/local/bin/dialog"
53 | dialogTitle="Homebrew Package Installs"
54 | dialogIcon="https://upload.wikimedia.org/wikipedia/commons/3/34/Homebrew_logo.png"
55 | declare -a theSteps
56 | theSteps=(
57 | "\"Getting List of Packages\""
58 | )
59 |
60 | for s in ${homebrewPackages//,/ }; do
61 | echo "$s"
62 | theSteps+=("\"$s\"")
63 | done
64 |
65 | theStepsLength="${#theSteps[@]}"
66 | currentStep=0
67 | dialogConfig=(
68 | "--title \"$dialogTitle\""
69 | "--icon \"$dialogIcon\""
70 | "--position topleft"
71 | "--message \" \""
72 | "--messagefont \"size=16\""
73 | # "--small"
74 | "--ontop"
75 | "--moveable"
76 | # "--position centre"
77 | "${theSteps[@]/#/--listitem }"
78 | )
79 | ###################################################
80 |
81 | ## Logging Function
82 | log_it () {
83 | if [[ ! -z "$1" && -z "$2" ]]; then
84 | logEvent="INFO"
85 | logMessage="$1"
86 | elif [[ "$1" == "warning" ]]; then
87 | logEvent="WARN"
88 | logMessage="$2"
89 | elif [[ "$1" == "success" ]]; then
90 | logEvent="SUCCESS"
91 | logMessage="$2"
92 | elif [[ "$1" == "error" ]]; then
93 | logEvent="ERROR"
94 | logMessage="$2"
95 | fi
96 |
97 | if [[ ! -z "$logEvent" ]]; then
98 | echo ">>[InstallHomebrewPackages.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage"
99 | echo ">>[InstallHomebrewPackages.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage" >> "$InstallHomebrewPackages"
100 | fi
101 | }
102 |
103 | update_dialog () {
104 | log_it "DIALOG: $1"
105 | echo "$1" >> "$dialogLogFile"
106 | }
107 |
108 | finish_dialog () {
109 | update_dialog "progresstext: Homebrew Package Installs Complete"
110 | sleep 1
111 | update_dialog "quit:"
112 | exit 0
113 | }
114 |
115 | rm "$dialogLogFile"
116 | eval "$dialogPath" "${dialogConfig[*]}" & sleep 1
117 |
118 | for (( i=0; i&1 | tee -a "$homebrewLog"
160 | # update_dialog "listitem: title: \"Updating Homebrew\", status: success"
161 | fi
162 |
163 | ### Tap brew tap saucelabs/saucectl
164 | su -l "$currentUser" -c "$homebrewPath tap saucelabs/saucectl" 2>&1 | tee -a "$homebrewLog"
165 | }
166 |
167 | install_packages () {
168 | # brew_packages="jq,wget,git,python,mint,carthage,watchman,chargepoint/xcparse/xcparse,danger/tap/danger-swift,nvm,saucectl"
169 |
170 | for p in ${brew_packages//,/ }; do
171 | log_it "Installing $p.."
172 | update_dialog "listitem: title: $p, status: wait"
173 | su -l "$currentUser" -c "$homebrewPath install $p" 2>&1 | tee -a "$homebrewLog"
174 | checkInstall=$(su -l "$currentUser" -c "$homebrewPath list $p" | grep "Error:")
175 | if [[ -z "$checkInstall" ]]; then
176 | log_it "success" "$p was installed successfully."
177 | update_dialog "listitem: title: $p, status: success"
178 | else
179 | log_it "error" "$p was unable to be installed. View Homebrew.log for details."
180 | update_dialog "listitem: title: $p, status: error"
181 | fi
182 | done
183 | }
184 |
185 | homebrew_check
186 | install_packages
187 | finish_dialog
--------------------------------------------------------------------------------
/Homebrew/InstallHomebrew.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2022, JAMF Software, LLC. All rights reserved.
6 | #
7 | # Redistribution and use in source and binary forms, with or without
8 | # modification, are permitted provided that the following conditions are met:
9 | # * Redistributions of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | # * Redistributions in binary form must reproduce the above copyright
12 | # notice, this list of conditions and the following disclaimer in the
13 | # documentation and/or other materials provided with the distribution.
14 | # * Neither the name of the JAMF Software, LLC nor the
15 | # names of its contributors may be used to endorse or promote products
16 | # derived from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
19 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | # DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
22 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | #
29 | # Author: Josh Harvey
30 | # Last Modified: 06/01/2022
31 | # Version: 0.1
32 | #
33 | # Description: This script will check to see if you have Xcode Command Line Tools installed
34 | # (it will install it if not found) then attempt to install Homebrew on your system.
35 | #
36 | ####################################################################################################
37 |
38 | ################# VARIABLES ######################
39 | ## xcodeCLITrigger: The name of the trigger on the policy that installs Xcode Command Line Tools **REQUIRED**
40 | xcodeCLITrigger="$4"
41 | ## currentUser: Grabs the username of the current logged in user **DO NOT CHANGE**
42 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }')
43 | ## installHomebrewLog: Location of the installHomebrew script log **DO NOT CHANGE**
44 | installHomebrewLog="/private/var/log/InstallHomebrew.log"
45 | ## homebrewLog: Location of the Homebrew log **DO NOT CHANGE**
46 | homebrewLog="/private/var/log/Homebrew.log"
47 | ## currentTime: Gets the time for the log **DO NOT CHANGE**
48 | currentTime=$(date +%H:%M)
49 |
50 | ### swiftDialog Variables
51 | dialogLogFile="/var/tmp/dialog.log"
52 | dialogPath="/usr/local/bin/dialog"
53 | dialogTitle="Homebrew Setup"
54 | dialogIcon="https://upload.wikimedia.org/wikipedia/commons/3/34/Homebrew_logo.png"
55 | theSteps=(
56 | "\"Install Xcode Command Line Tools\""
57 | "\"Install Homebrew\""
58 | "\"Install md5sha1sum (Homebrew)\""
59 | "\"Apply Permissions\""
60 | "\"Check for Updates\""
61 | )
62 | theStepsLength="${#theSteps[@]}"
63 | currentStep=0
64 | dialogConfig=(
65 | "--title \"$dialogTitle\""
66 | "--icon \"$dialogIcon\""
67 | "--position topleft"
68 | "--message \" \""
69 | "--messagefont \"size=16\""
70 | # "--small"
71 | "--ontop"
72 | "--moveable"
73 | # "--position centre"
74 | "${theSteps[@]/#/--listitem }"
75 | )
76 | ###################################################
77 |
78 | ## Logging Function
79 | log_it () {
80 | if [[ ! -z "$1" && -z "$2" ]]; then
81 | logEvent="INFO"
82 | logMessage="$1"
83 | elif [[ "$1" == "warning" ]]; then
84 | logEvent="WARN"
85 | logMessage="$2"
86 | elif [[ "$1" == "success" ]]; then
87 | logEvent="SUCCESS"
88 | logMessage="$2"
89 | elif [[ "$1" == "error" ]]; then
90 | logEvent="ERROR"
91 | logMessage="$2"
92 | fi
93 |
94 | if [[ ! -z "$logEvent" ]]; then
95 | echo ">>[InstallHomebrew.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage"
96 | echo ">>[InstallHomebrew.sh] :: $logEvent [$(date +%H:%M)] :: $logMessage" >> "$installHomebrewLog"
97 | fi
98 | }
99 |
100 | update_dialog () {
101 | log_it "DIALOG: $1"
102 | echo "$1" >> "$dialogLogFile"
103 | }
104 |
105 | finish_dialog () {
106 | update_dialog "progresstext: Homebrew Setup Complete"
107 | sleep 1
108 | update_dialog "quit:"
109 | exit 0
110 | }
111 |
112 | if [[ -z "$xcodeCLITrigger" ]]; then
113 | log_it "error" "Missing Xcode Command Line Tools Trigger in Script Parameter #4."
114 | exit 1
115 | fi
116 |
117 | rm "$dialogLogFile"
118 | eval "$dialogPath" "${dialogConfig[*]}" & sleep 1
119 |
120 | for (( i=0; i "/Users/Shared/xcodecliversion"
143 | fi
144 | else
145 | log_it "Xcode Command Line Tools are not installed.. Lets install them now!"
146 | update_dialog "listitem: index: $((currentStep)), status: wait"
147 | /usr/local/bin/jamf policy -event $xcodeCLITrigger
148 | xcodeCLIVersion=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep "version:" | sed 's/[version: ]//g')
149 | if [[ ! -z "$xcodeCLIVersion" ]]; then
150 | log_it "success" "Xcode Command Line Tools (Version: $xcodeCLIVersion) was successfully installed."
151 | update_dialog "listitem: index: $((currentStep++)), status: success"
152 | echo "$xcodeCLIVersion" > "/Users/Shared/xcodecliversion"
153 | xcodeCLI="Installed"
154 | else
155 | xcodeCLI="Missing"
156 | fi
157 | fi
158 |
159 | ## User Group Check
160 | devGroupCheck=$(groups "$currentUser" | grep -o '_developer')
161 | if [[ -z "$devGroupCheck" ]]; then
162 | /usr/sbin/dseditgroup -o edit -a "$currentUser" -t user _developer
163 | log_it "success" "Added $currentUser to the _developer group."
164 | else
165 | log_it "$currentUser is already a member of the _developer group."
166 | fi
167 | }
168 |
169 |
170 | install_homebrew () {
171 | update_dialog "listitem: index: $((currentStep)), status: wait"
172 | ## Lets see what architecture the system is..
173 | macOSArch=$(/usr/bin/uname -m)
174 |
175 | if [[ "$macOSArch" == "x86_64" ]]; then
176 | log_it "System Architecture: Intel (64-Bit)"
177 | homebrewPath="/usr/local/bin/brew"
178 | homebrewDir="/usr/local/Homebrew"
179 | # log_it "Setting Homebrew Directory to: $homebrewDir"
180 | elif [[ "$macOSArch" == "arm64" ]]; then
181 | log_it "System Architecture: Apple Silicon 64-Bit"
182 | homebrewPath="/opt/homebrew/bin/brew"
183 | homebrewDir="/opt/homebrew"
184 | # log_it "Setting Homebrew Directory to: $homebrewDir"
185 | fi
186 |
187 |
188 | if [[ ! -e "$homebrewPath" ]]; then
189 | log_it "Starting Homebrew installation.."
190 |
191 | mkdir -p "$homebrewDir"
192 | ## Curl down the latest tarball and install to "$homebrewDir"
193 | curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C $homebrewDir && log_it "Homebrew downloaded successfully."
194 |
195 | if [[ ! -e $homebrewDir ]]; then
196 | log_it "error" "Homebrew failed to download."
197 | exit 1
198 | fi
199 |
200 | ## Manually make all the appropriate directories and set permissions
201 | log_it "Creating Homebrew directories and setting permissions for user $currentUser"
202 |
203 | if [[ "$macOSArch" == "x86_64" ]]; then
204 | log_it "System Architecture: Intel (64-Bit)"
205 | mkdir -p /usr/local/Cellar /usr/local/Homebrew mkdir /usr/local/Caskroom /usr/local/Frameworks /usr/local/bin
206 | mkdir -p /usr/local/include /usr/local/lib /usr/local/opt /usr/local/etc /usr/local/sbin
207 | mkdir -p /usr/local/share/zsh/site-functions /usr/local/var
208 | mkdir -p /usr/local/share/doc /usr/local/man/man1 /usr/local/share/man/man1
209 | chown -R "$currentUser:_developer" /usr/local/*
210 | chmod -R g+rwx /usr/local/*
211 | chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
212 | ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
213 | elif [[ "$macOSArch" == "arm64" ]]; then
214 | log_it "System Architecture: Apple Silicon 64-Bit"
215 | mkdir -p /opt/homebrew/Cellar mkdir /opt/homebrew/Caskroom /opt/homebrew/Frameworks /opt/homebrew/bin
216 | mkdir -p /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/opt /opt/homebrew/etc /opt/homebrew/sbin
217 | mkdir -p /opt/homebrew/share/zsh/site-functions /opt/homebrew/var
218 | mkdir -p /opt/homebrew/share/doc /opt/homebrew/man/man1 /opt/homebrew/share/man/man1
219 | chown -R "$currentUser:_developer" /opt/homebrew
220 | echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
221 | eval "$(/opt/homebrew/bin/brew shellenv)"
222 | fi
223 |
224 | update_dialog "listitem: index: $((currentStep++)), status: success"
225 |
226 | log_it "Creating system wide cache folder."
227 | # Create a system wide cache folder
228 | mkdir -p /Library/Caches/Homebrew
229 | chmod g+rwx /Library/Caches/Homebrew
230 | chown "$currentUser:_developer" /Library/Caches/Homebrew
231 |
232 | log_it "Installing the MD5 Checker for Homebrew."
233 | update_dialog "listitem: index: $((currentStep)), status: wait"
234 | # Install the MD5 checker or the recipes will fail
235 | su -l "$currentUser" -c "$homebrewPath install md5sha1sum"
236 | echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' |
237 | tee -a /Users/"$currentUser"/.bash_profile /Users/"$currentUser"/.zshrc
238 | chown "$currentUser" /Users/"$currentUser"/.bash_profile /Users/"$currentUser"/.zshrc
239 | update_dialog "listitem: index: $((currentStep++)), status: success"
240 |
241 | log_it "Setting permissions."
242 | update_dialog "listitem: index: $((currentStep)), status: wait"
243 | # Fix the permissions
244 | chown -R root:wheel /private/tmp
245 | chmod 777 /private/tmp
246 | chmod +t /private/tmp
247 | update_dialog "listitem: index: $((currentStep++)), status: success"
248 |
249 | log_it "success" "Homebrew was successfully installed! Lets double check there aren't any updates available!"
250 | update_dialog "listitem: index: $((currentStep)), status: wait"
251 | su -l "$currentUser" -c "$homebrewPath update" 2>&1 | tee -a "$homebrewLog"
252 | update_dialog "listitem: index: $((currentStep++)), status: success"
253 | else
254 | log_it "success" "Homebrew is already installed. Checking for any updates now.."
255 | update_dialog "listitem: index: $((currentStep++)), status: success"
256 | update_dialog "listitem: index: $((currentStep++)), status: success"
257 | update_dialog "listitem: index: $((currentStep++)), status: success"
258 | update_dialog "listitem: index: $((currentStep++)), status: success"
259 | update_dialog "listitem: index: $((currentStep)), status: wait"
260 | su -l "$currentUser" -c "$homebrewPath update" 2>&1 | tee -a "$homebrewLog"
261 | update_dialog "listitem: index: $((currentStep++)), status: success"
262 | fi
263 | }
264 |
265 | if [[ -z "$xcodeCLITrigger" ]]; then
266 | log_it "error" "The xcodeCLITrigger variable is empty. Make sure you put the trigger of the policy that's installing Xcode Command Line Tools in the xcodeCLITrigger variable on Line 42, then try running the script again."
267 | exit 1
268 | else
269 | log_it "Starting the requirements check to see if Xcode CLI is installed and $currentUser is a member of the correct group."
270 | requirements_check
271 | if [[ "$xcodeCLI" == "Installed" ]]; then
272 | install_homebrew
273 | finish_dialog
274 | else
275 | log_it "error" "Unable to install Homebrew due to Xcode Command Line Tools not being found. Please verify that Xcode Command Line Tools is installed then try running this script again."
276 | update_dialog "listitem: index: $((currentStep++)), status: fail"
277 | update_dialog "listitem: index: $((currentStep++)), status: fail"
278 | update_dialog "listitem: index: $((currentStep++)), status: fail"
279 | update_dialog "listitem: index: $((currentStep++)), status: fail"
280 | update_dialog "listitem: index: $((currentStep++)), status: fail"
281 | exit 1
282 | fi
283 | fi
284 |
285 |
--------------------------------------------------------------------------------