install-ubuntu-git.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. elif [ "$UBUNTU_DISTRO" == "noble" ]
  33. then
  34. echo "Setup for Ubuntu 24.04 LTS ($UBUNTU_DISTRO)"
  35. else
  36. echo "Unsupported version of Ubuntu $UBUNTU_DISTRO"
  37. exit 1
  38. fi
  39. #
  40. # Setup and get the latest from git if necessary
  41. #
  42. git --version > /dev/null 2>&1
  43. if [ $? -ne 0 ]
  44. then
  45. echo Setting up latest version of GIT
  46. add-apt-repository ppa:git-core/ppa -y
  47. apt-get update
  48. apt-get install git -y
  49. else
  50. GIT_VERSION=$(git --version | awk '{print $3}')
  51. echo Git $GIT_VERSION already Installed. Skipping Git installation
  52. fi
  53. #
  54. # Setup Git-LFS if needed
  55. #
  56. GIT_LFS_PACKAGE_COUNT=$(apt list --installed 2>/dev/null | grep git-lfs/ | wc -l)
  57. if [ $GIT_LFS_PACKAGE_COUNT -eq 0 ]
  58. then
  59. echo Setting up Git-LFS
  60. pushd /tmp
  61. wget https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh -o script.deb.sh
  62. rm script.deb.sh
  63. mv script.deb.sh.1 script.deb.sh
  64. chmod +x script.deb.sh
  65. ./script.deb.sh
  66. sudo apt-get install git-lfs -y
  67. popd
  68. else
  69. echo Git LFS already installed. Skipping Git-LFS installation
  70. fi
  71. # Setup GCM if needed
  72. git-credential-manager-core --version > /dev/null 2>&1
  73. if [ $? -ne 0 ]
  74. then
  75. # Download and setup Git Credential Manager
  76. GCM_PACKAGE_NAME=gcmcore-linux_amd64.2.0.394.50751.deb
  77. GCM_PACKAGE_URL=https://github.com/microsoft/Git-Credential-Manager-Core/releases/download/v2.0.394-beta
  78. echo Installing Git Credential Manager \($GCM_PACKAGE_NAME\)
  79. pushd /tmp > /dev/null
  80. curl --location $GCM_PACKAGE_URL/$GCM_PACKAGE_NAME -o $GCM_PACKAGE_NAME
  81. dpkg -i $GCM_PACKAGE_NAME
  82. popd
  83. else
  84. GCM_VERSION=$(git-credential-manager-core --version)
  85. echo Git Credential Manager \(GCM\) version $GCM_VERSION already installed. Skipping GCM installation
  86. fi
  87. # Setup pass (password manager) for git-credential-manager
  88. apt-get install pass -y