drone/app/gitspace/orchestrator/git/script/install_git.sh
Vikyath Harekal 4c278448c4 feat: [CDE-332]: Update the gitspace setup scripts to support more OSes (#2872)
* feat: [CDE-332]: Update the gitspace setup scripts to support more OSes
2024-10-26 11:42:12 +00:00

52 lines
1.0 KiB
Bash

#!/bin/sh
# Source the common OS info script
. ../../common/script/os_info.sh
# Install Git if not already installed
install_git() {
# Check if Git is installed
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed. Installing Git..."
case "$(distro)" in
debian | ubuntu)
apt-get update && apt-get install -y git
;;
fedora | centos | rhel)
dnf install -y git
;;
opensuse)
zypper install -y git
;;
alpine)
apk add git
;;
arch | manjaro)
pacman -Sy --noconfirm git
;;
freebsd)
pkg install -y git
;;
macos)
brew install git
;;
*)
echo "Unsupported OS for automatic Git installation."
return 1
;;
esac
fi
# Verify installation
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed. Exiting..."
exit 1
else
echo "Git is installed."
fi
}
# Run the installation function
install_git