[原创]centos 6.x简易安装git 脚本 – 21运维
通知: .-...

[原创]centos 6.x简易安装git 脚本

Git 21运维 3944浏览 0评论

每次拿到新机器,比较烦恼的是安装各种工具,比如这种git,yum的版本过低,最好自己编译一个。这里简单写了一个测试可用,不用每次都按照步骤操作了。

当然,也可以集成到系统初始化脚本中用于调用,或者写入到saltstack的sls文档中用于系统初始化都是可用的,这里不做展示,写出来也只是拿来对个别机器安装而已。

#!/bin/bash
# install  git for centos 6.x
#author:21yunwei
#date:2016.1.29

downloaddir=/usr/local/src
cpunum=`cat  /proc/cpuinfo |grep  -c processor`

function msg_notice(){
if [ $? -eq 0 ] ;then
	echo "Install  sucess"
else
	echo "Install  failed,please check"
	exit
fi
}

function  install_git(){

echo "Install  packages about git,please wait........"
yum install  perl cpio curl curl-devel  zlib-devel openssl-develexpat-devel  gettext-devel -y >/dev/null  
yum install  perl-ExtUtils-Embed -y  >/dev/null
msg_notice
echo "Downloading  git source code,please wait...."
wget -c  https://github.com/git/git/archive/v2.11.0-rc1.tar.gz -P $downloaddir
tar zxf ${downloaddir}/v2.11.0-rc1.tar.gz -C  $downloaddir
cd ${downloaddir}/git-2.11.0-rc1  && make configure && ./configure   --prefix=/usr/local/git && make -j${cpunum} &&make install
msg_notice
}

function  gitpath_version(){
echo "export PATH=/usr/local/git/bin:$PATH" >> /etc/profile && source  /etc/profile
gitversion=`git --version`
echo "Install git finished,git version is:$gitversion"

}

function juage_git(){
which git >/dev/null 2>&1
if [ $? -ne  0  ]
then
	cat  < 

转载请注明:21运维 » [原创]centos 6.x简易安装git 脚本

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址