install-ubuntu-git.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. #
  14. # Make sure we are installing on a supported ubuntu distro
  15. #
  16. lsb_release -c >/dev/null 2>&1
  17. if [ $? -ne 0 ]
  18. then
  19. echo This script is only supported on Ubuntu Distros
  20. exit 1
  21. fi
  22. UBUNTU_DISTRO="$(lsb_release -c | awk '{print $2}')"
  23. if [ "$UBUNTU_DISTRO" == "bionic" ]
  24. then
  25. echo "Setup for Ubuntu 18.04 LTS ($UBUNTU_DISTRO)"
  26. elif [ "$UBUNTU_DISTRO" == "focal" ]
  27. then
  28. echo "Setup for Ubuntu 20.04 LTS ($UBUNTU_DISTRO)"
  29. elif [ "$UBUNTU_DISTRO" == "jammy" ]
  30. then
  31. echo "Setup for Ubuntu 22.04 LTS ($UBUNTU_DISTRO)"
  32. else
  33. echo "Unsupported version of Ubuntu $UBUNTU_DISTRO"
  34. exit 1
  35. fi
  36. #
  37. # Setup and get the latest from git if necessary
  38. #
  39. git --version > /dev/null 2>&1
  40. if [ $? -ne 0 ]
  41. then
  42. echo Setting up latest version of GIT
  43. add-apt-repository ppa:git-core/ppa -y
  44. apt-get update
  45. apt-get install git -y
  46. else
  47. GIT_VERSION=$(git --version | awk '{print $3}')
  48. echo Git $GIT_VERSION already Installed. Skipping Git installation
  49. fi
  50. #
  51. # Setup Git-LFS if needed
  52. #
  53. GIT_LFS_PACKAGE_COUNT=$(apt list --installed 2>/dev/null | grep git-lfs/ | wc -l)
  54. if [ $GIT_LFS_PACKAGE_COUNT -eq 0 ]
  55. then
  56. echo Setting up Git-LFS
  57. pushd /tmp
  58. wget https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh -o script.deb.sh
  59. rm script.deb.sh
  60. mv script.deb.sh.1 script.deb.sh
  61. chmod +x script.deb.sh
  62. ./script.deb.sh
  63. sudo apt-get install git-lfs -y
  64. popd
  65. else
  66. echo Git LFS already installed. Skipping Git-LFS installation
  67. fi
  68. # Setup GCM if needed
  69. git-credential-manager-core --version > /dev/null 2>&1
  70. if [ $? -ne 0 ]
  71. then
  72. # Download and setup Git Credential Manager
  73. GCM_PACKAGE_NAME=gcmcore-linux_amd64.2.0.394.50751.deb
  74. GCM_PACKAGE_URL=https://github.com/microsoft/Git-Credential-Manager-Core/releases/download/v2.0.394-beta
  75. echo Installing Git Credential Manager \($GCM_PACKAGE_NAME\)
  76. pushd /tmp > /dev/null
  77. curl --location $GCM_PACKAGE_URL/$GCM_PACKAGE_NAME -o $GCM_PACKAGE_NAME
  78. dpkg -i $GCM_PACKAGE_NAME
  79. popd
  80. else
  81. GCM_VERSION=$(git-credential-manager-core --version)
  82. echo Git Credential Manager \(GCM\) version $GCM_VERSION already installed. Skipping GCM installation
  83. fi
  84. # Setup pass (password manager) for git-credential-manager
  85. apt-get install pass -y