github.com/lacework-dev/go-moby@v20.10.12+incompatible/contrib/mac-install-bundle.sh (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  errexit() {
     6  	echo "$1"
     7  	exit 1
     8  }
     9  
    10  [ "$(uname -s)" == "Darwin" ] || errexit "This script can only be used on a Mac"
    11  
    12  [ $# -eq 1 ] || errexit "Usage: $0 install|undo"
    13  
    14  BUNDLE="bundles/$(cat VERSION)"
    15  BUNDLE_PATH="$PWD/$BUNDLE"
    16  CLIENT_PATH="$BUNDLE_PATH/cross/darwin/amd64/docker"
    17  DATABASE="$HOME/Library/Containers/com.docker.docker/Data/database"
    18  DATABASE_KEY="$DATABASE/com.docker.driver.amd64-linux/bundle"
    19  
    20  [ -d "$DATABASE" ] || errexit "Docker for Mac must be installed for this script"
    21  
    22  case "$1" in
    23  	"install")
    24  		[ -d "$BUNDLE" ] || errexit "cannot find bundle $BUNDLE"
    25  		[ -e "$CLIENT_PATH" ] || errexit "you need to run make cross first"
    26  		[ -e "$BUNDLE/binary-daemon/dockerd" ] || errexit "you need to build binaries first"
    27  		[ -f "$BUNDLE/binary-client/docker" ] || errexit "you need to build binaries first"
    28  		git -C "$DATABASE" reset --hard > /dev/null
    29  		echo "$BUNDLE_PATH" > "$DATABASE_KEY"
    30  		git -C "$DATABASE" add "$DATABASE_KEY"
    31  		git -C "$DATABASE" commit -m "update bundle to $BUNDLE_PATH"
    32  		rm -f /usr/local/bin/docker
    33  		cp "$CLIENT_PATH" /usr/local/bin
    34  		echo "Bundle installed. Restart Docker to use. To uninstall, reset Docker to factory defaults."
    35  		;;
    36  	"undo")
    37  		git -C "$DATABASE" reset --hard > /dev/null
    38  		[ -f "$DATABASE_KEY" ] || errexit "bundle not set"
    39  		git -C "$DATABASE" rm "$DATABASE_KEY"
    40  		git -C "$DATABASE" commit -m "remove bundle"
    41  		rm -f /usr/local/bin/docker
    42  		ln -s "$HOME/Library/Group Containers/group.com.docker/bin/docker" /usr/local/bin
    43  		echo "Bundle removed. Using dev versions may cause issues, a reset to factory defaults is recommended."
    44  		;;
    45  esac