From 445f2cee2ef35ded3ae26803ea02af63e21a946f Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Tue, 22 Aug 2023 10:09:50 +1000 Subject: [PATCH] prompt user to acknowledge installation of coreutils on macos --- docker/docker.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docker/docker.sh b/docker/docker.sh index 8b48b303..2f56cd18 100755 --- a/docker/docker.sh +++ b/docker/docker.sh @@ -3,6 +3,29 @@ trap "echo; exit" INT trap "echo; exit" HUP +# install `realpath` on macOS from Homebrew `coreutils` +# reference: https://unix.stackexchange.com/a/336138/269147 +if [[ "$OSTYPE" == "darwin"* ]]; then + set -e + printf "\n*** Mac OS (Darwin) detected." + printf "\n*** Installation of Homebrew and coreutils is required by this script." + printf "\n*** Press SPACE to continue the installation or Ctrl+C to exit..." + while true; do + read -n1 -r + [[ $REPLY == ' ' ]] && break + done + printf "\n*** Continuing..." + + if ! which brew >/dev/null 2>&1; then + printf "\n*** Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + fi + + brew update + printf "\n*** Installing coreutils..." + brew install coreutils +fi + PARENT_DIR=$( echo $(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")") ) # generate .env file from .env.example if it does not exist # https://stackoverflow.com/a/47677632/3208553