Created
October 13, 2013 05:27
-
-
Save danijeljw/6958488 to your computer and use it in GitHub Desktop.
Install Git (req. cURL) on Linux in 1-step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Linux Auto-Install Git | |
# | |
# Copyright (c) 2012 Danijel James http://danijelj.com | |
# | |
# Licensed under MIT | |
# version number | |
version="1.0.5" | |
# request `sudo` access | |
function reqSudo { | |
sudo -v | |
} | |
# keep-alive | |
function keepAlive { | |
while true; do sudo -n true; sleep 60; kill -0 '$$' || exit; done 2>/dev/null & | |
} | |
# Function Show script help | |
function showHelp { | |
clear | |
echo "Linux Auto-Install Git $version" | |
echo "Copyright © 2012 Danijel James" | |
echo | |
echo 'Usage: $0 [option]' | |
echo | |
echo 'Options:' | |
echo ' -h | --help This help file' | |
echo ' -i | --install Install Git without updating packages' | |
echo ' -u | --update-install Update packages and install Git' | |
echo | |
echo | |
} | |
# apt-get upgrade full | |
function agUpdateFull { | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get autoremove | |
sudo apt-get autoclean | |
} | |
# apt-get upgrade | |
function agUpdate { | |
sudo apt-get update | |
} | |
# install Git dependencies | |
function gitDepends { | |
sudo apt-get -y install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev | |
} | |
# install git | |
function gitInstall { | |
git clone git://git.kernel.org/pub/scm/git/git.git | |
cd git | |
make prefix=/usr/local all | |
sudo make prefix=/usr/local install | |
} | |
# call Install | |
function callI { | |
reqSudo | |
keepAlive | |
agUpdate | |
gitDepends | |
gitInstall | |
} | |
# call Update-Install | |
function callU { | |
reqSudo | |
keepAlive | |
agUpdateFull | |
gitDepends | |
gitInstall | |
} | |
# Main method starts here | |
case $1 in | |
-h | --help ) showHelp | |
exit | |
;; | |
-i | --install ) callI | |
exit | |
;; | |
-u | --update-install ) callS | |
exit | |
;; | |
* ) showHelp | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to Google Code https://code.google.com/p/add-my-git/
This version has been depreciated.