macos homebrew unattended cask installs
Shell
#!/bin/bash
# Script to install Homebrew on a Mac.
# Author: richard at richard - purves dot com
# Version: 1.0 - 21st May 2017
# Set up variables and functions here
consoleuser="$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')"
brandid="com.application.id"
tn="/path/to/terminal-notifier.app/Contents/MacOS/terminal-notifier"
cd="/path/to/cocoaDialog.app/Contents/MacOS/cocoaDialog"
# Logging stuff starts here
LOGFOLDER="/private/var/log/"
LOG=$LOGFOLDER"Homebrew.log"
if [ ! -d "$LOGFOLDER" ];
then
mkdir $LOGFOLDER
fi
function logme()
{
# Check to see if function has been called correctly
if [ -z "$1" ]
then
echo $( date )" - logme function call error: no text passed to function! Please recheck code!"
echo $( date )" - logme function call error: no text passed to function! Please recheck code!" >> $LOG
exit 1
fi
# Log the passed details
echo -e $( date )" - $1" >> $LOG
echo -e $( date )" - $1"
}
function notify()
{
su -l "$consoleuser" -c " "'"'$tn'"'" -sender "'"'$brandid'"'" -title "'"'$title'"'" -message "'"'$1'"'" "
logme "$1"
}
# Check and start logging - done twice for local log and for JAMF
logme "Homebrew Installation"
# Let's start here by caffinating the mac so it stays awake or bad things happen.
caffeinate -d -i -m -u &
caffeinatepid=$!
logme "Caffinating the mac under process id: $caffeinatepid"
# Have the xcode command line tools been installed?
notify "Checking for Xcode Command Line Tools installation"
check=$( pkgutil --pkgs | grep com.apple.pkg.CLTools_Executables | wc -l | awk '{ print $1 }' )
if [[ "$check" != 1 ]];
then
notify "Installing Xcode Command Tools"
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
clt=$(softwareupdate -l | grep -B 1 -E "Command Line (Developer|Tools)" | awk -F"*" '/^ +\\*/ {print $2}' | sed 's/^ *//' | tail -n1)
softwareupdate -i "$clt"
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
/usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
fi
# Is homebrew already installed?
which -s brew
if [[ $? = 1 ]];
then
# Install Homebrew. This doesn't like being run as root so we must do this manually.
notify "Installing Homebrew"
# Curl down the latest tarball and install to /usr/local
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /usr/local
# Manually make all the appropriate directories and set permissions
mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
chown -R $consoleuser /usr/local
chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
# Create a system wide cache folder
mkdir -p /Library/Caches/Homebrew
chmod g+rwx /Library/Caches/Homebrew
chown $consoleuser:wheel /Library/Caches/Homebrew
# Install the MD5 checker or the recipes will fail
su -l "$consoleuser" -c "/usr/local/bin/brew install md5sha1sum"
su -l "$consoleuser" -c "echo "'"export PATH=/usr/local/opt/openssl/bin:$PATH"'" >> ~/.bash_profile"
# Remove temporary folder
rm -rf /usr/local/Homebrew
else
# Run an update and quit
notify "Updating Homebrew"
su -l "$consoleuser" -c "/usr/local/bin/brew update" 2>&1 | tee -a ${LOG}
exit 0
fi
# Make sure everything is up to date
notify "Updating Homebrew"
su -l "$consoleuser" -c "/usr/local/bin/brew update" 2>&1 | tee -a ${LOG}
# Notify user that all is completed
notify "Installation complete"
# No more caffeine please. I've a headache.
kill "$caffeinatepid"
exit 0
Also in Shell:
- Title
- linux search for line in file
- Category
- Shell
- Title
- install docker debain
- Category
- Shell
- Title
- create directory linux
- Category
- Shell
- Title
- install react react testing library
- Category
- Shell
- Title
- how to connect to the database as root user in linux
- Category
- Shell
- Title
- matrix synapse install
- Category
- Shell
- Title
- Running modprobe bridge br_netfilter failed with message: ip: can't find device
- Category
- Shell
- Title
- git reset hard
- Category
- Shell
- Title
- how to install react spring
- Category
- Shell
- Title
- bash compare two strings
- Category
- Shell
- Title
- cancel commit before push
- Category
- Shell
- Title
- install snap change in progress ubuntu
- Category
- Shell
- Title
- git add
- Category
- Shell
- Title
- change ratio vmware ubuntu
- Category
- Shell
- Title
- install dateutil
- Category
- Shell
- Title
- shutdown timer windows 10
- Category
- Shell
- Title
- installing git on mac
- Category
- Shell
- Title
- how to tar linux
- Category
- Shell
- Title
- Shell/BAsh
- Category
- Shell
- Title
- linux check timezone
- Category
- Shell
- Title
- unknown type name 'CDVUIWebViewDelegate' CDVUIWebViewDelegate* _webViewDelegate;
- Category
- Shell
- Title
- docker build
- Category
- Shell
- Title
- git add .
- Category
- Shell
- Title
- desktop trigger click bash shell ubuntu
- Category
- Shell
- Title
- bash ls without substring
- Category
- Shell
- Title
- how to uninstall npm package
- Category
- Shell
- Title
- git grep across all branches
- Category
- Shell
- Title
- install ext-soap
- Category
- Shell
- Title
- linux grep
- Category
- Shell
- Title
- package 'mana-toolkit' has no installation candidate
- Category
- Shell
- Title
- wheres i3 config file
- Category
- Shell
- Title
- git ignore
- Category
- Shell
- Title
- command to find out my git head version
- Category
- Shell
- Title
- how to know free space in linux
- Category
- Shell
- Title
- git config core.autocrlf true
- Category
- Shell
- Title
- composer drupal install
- Category
- Shell
- Title
- obs
- Category
- Shell
- Title
- node install specific version
- Category
- Shell
- Title
- remove .svn recursively linux
- Category
- Shell
- Title
- "at" ubuntu script dschedule
- Category
- Shell
- Title
- pod deintegrate
- Category
- Shell
- Title
- find exclude hidden files
- Category
- Shell
- Title
- Could not install Visual Studio Build Tools.
- Category
- Shell
- Title
- find out a branch a parent branch git
- Category
- Shell
- Title
- mkdir linux
- Category
- Shell
- Title
- bash rename file
- Category
- Shell
- Title
- linux command for file size
- Category
- Shell
- Title
- converter mp3 para kali linux
- Category
- Shell
- Title
- view memory usage linux
- Category
- Shell
- Title
- whats up with docker compose and orphan containers
- Category
- Shell
- Title
- remove yum package
- Category
- Shell
- Title
- force pull github
- Category
- Shell
- Title
- gpg: can't connect to the agent: IPC connect call failed
- Category
- Shell
- Title
- install openjdk 8 sdk on ubuntu
- Category
- Shell
- Title
- list config git
- Category
- Shell
- Title
- ubuntu install composer
- Category
- Shell
- Title
- powershell check if software is installed
- Category
- Shell
- Title
- how to install pytorch 0.4.1
- Category
- Shell
- Title
- how to kill tasks using grep
- Category
- Shell
- Title
- ubuntu ram type
- Category
- Shell
- Title
- deletar branch
- Category
- Shell
- Title
- ubuntu camera not longer found
- Category
- Shell
- Title
- shell set environment variable
- Category
- Shell
- Title
- ubuntu check process on port
- Category
- Shell
- Title
- vagrant ubuntu 16.04
- Category
- Shell
- Title
- powershell get arguments
- Category
- Shell
- Title
- git rebase
- Category
- Shell
- Title
- install wpscan in linux server globally
- Category
- Shell
- Title
- choco installation
- Category
- Shell
- Title
- upgrade aws cli
- Category
- Shell
- Title
- bash list of integers
- Category
- Shell
- Title
- netstat column headers
- Category
- Shell
- Title
- install idle on ubuntu
- Category
- Shell
- Title
- pip3 not found
- Category
- Shell
- Title
- webpack uninstall npm
- Category
- Shell
- Title
- linux change file name
- Category
- Shell
- Title
- bazel instal
- Category
- Shell
- Title
- How to download Citrix Workspace for Ubuntu
- Category
- Shell
- Title
- how to list all versions of pip in ubuntu using grep
- Category
- Shell
- Title
- connection failed blueman.bluez.errors.dbusfailederror protocol not available
- Category
- Shell
- Title
- undo git pull origin master into feature branch
- Category
- Shell
- Title
- git log display files changed
- Category
- Shell
- Title
- fatal: could not read Username for 'https://github.com': Device not configured push crontab
- Category
- Shell
- Title
- bash for interval
- Category
- Shell
- Title
- pip upgrade
- Category
- Shell
- Title
- how to unstage changes in git
- Category
- Shell
- Title
- compress folder ubuntu
- Category
- Shell
- Title
- how to grep if the first letter is a character not a number
- Category
- Shell
- Title
- import jar file
- Category
- Shell
- Title
- install numpy
- Category
- Shell
- Title
- update flutter
- Category
- Shell
- Title
- linux change directory
- Category
- Shell
- Title
- install magento 2 command line composer
- Category
- Shell
- Title
- git show staged files
- Category
- Shell
- Title
- check 64 or 32 bit linux
- Category
- Shell
- Title
- git branch and checkout at the same time
- Category
- Shell
- Title
- react lorem ipsum
- Category
- Shell
- Title
- ubuntu create a ssh key
- Category
- Shell
- Title
- shell script to check the output of a file
- Category
- Shell
- Title
- serverless invoke sqs
- Category
- Shell