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

每次拿到新机器,比较烦恼的是安装各种工具,比如这种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  < 

转载请注明:西数超哥博客www.ysidc.top» [原创]centos 6.x简易安装git 脚本

https://www.ysidc.top 西数超哥博客,数据库,西数超哥,虚拟主机,域名注册,域名,云服务器,云主机,云建站,ysidc.top

西数超哥学习乐园,西数超哥基础运维经验教程分享的学习乐园,西数超哥博客,运维经验教程交流学习分享的博客

原创文章,作者:zhang sir,如若转载,请注明出处:https://www.ysidc.top/4999.html