mac-install-bundle.sh 1.6 KB

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