Created
October 16, 2013 20:44
-
-
Save adamcstephens/7014526 to your computer and use it in GitHub Desktop.
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 | |
[ -e /etc/os-release ] && . /etc/os-release | |
[ ! -z $ID ] && DIST=$ID | |
[ ! -z $ID_LIKE ] && DIST=$ID_LIKE | |
[ -e /etc/redhat-release ] && DIST='redhat' | |
[ -z $DIST ] && echo 'Unknown distribution.' && exit 2 | |
export DIST | |
function install_pkg_aur () { | |
[ -z $1 ] && echo "must pass pkg name" && return 4 | |
pkg=$1 | |
pkgsh=`echo $pkg | head -c2` | |
# skip if already installed | |
pacman -Q $pkg >/dev/null 2>&1 && return 4 | |
cd /tmp | |
curl -O https://aur.archlinux.org/packages/$pkgsh/$pkg/$pkg.tar.gz | |
tar zxvf $pkg.tar.gz | |
cd $pkg | |
makepkg --asroot -s -i --noconfirm | |
} | |
function install_pkg () { | |
[ -z $1 ] && echo "must pass pkg name" && return 4 | |
pkg=$1 | |
case $DIST in | |
'arch') | |
pacman -Q $pkg >/dev/null 2>&1 || pacman -S --noconfirm $pkg | |
;; | |
'debian') | |
dpkg -s $pkg > /dev/null 2>&1 || apt-get -y install $pkg | |
;; | |
'redhat') | |
rpm -q $pkg > /dev/null 2>&1 || yum -y install $pkg | |
;; | |
*) | |
echo "Unknown distribution" | |
;; | |
esac | |
return $? | |
} | |
function setup_dist () { | |
case $DIST in | |
'arch') | |
pacman -Sy | |
install_pkg_aur cower | |
install_pkg_aur pacaur | |
;; | |
'debian') | |
apt-get update | |
;; | |
'redhat') | |
if uname -r | grep el6 > /dev/null 2>&1 | |
then | |
rpm -q rpmforge-release >/dev/null 2>&1 || install_pkg http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm && sed -i 's/enabled = 1/enabled = 0/' /etc/yum.repos.d/rpmforge.repo | |
if ! which git >/dev/null 2>&1 | |
then | |
yum -y --enablerepo=rpmforge-extras install git | |
elif git --version | grep '1.7.1' >/dev/null 2>&1 | |
then | |
yum -y --enablerepo=rpmforge-extras update git | |
fi | |
fi | |
;; | |
*) | |
echo "Unknown distribution" | |
;; | |
esac | |
} | |
function setup_environment () { | |
cd ~ | |
[ -e .dotfiles ] && return 1 | |
echo "Setting up environment" | |
rm -f .bash_profile | |
rm -f .bashrc | |
rm -rf .vim* | |
rm -f .screenrc | |
rm -f .zshrc | |
FRESH_LOCAL_SOURCE=adamcstephens/dotfiles bash -c "`curl -sL get.freshshell.com`" | |
cd .dotfiles | |
git remote set-url --push origin https://[email protected]/adamcstephens/dotfiles.git | |
cd .. | |
chsh -s `which zsh` | |
vim +BundleInstall +qall | |
cat > /etc/profile.d/bootstrap.sh <<EOF | |
# Configure interactive shell... | |
if [ ! -z "\$PS1" ]; then | |
if [ "\`whoami\`" = "vagrant" ]; then | |
exec sudo su - | |
fi | |
fi | |
EOF | |
} | |
install_pkg curl | |
setup_dist | |
install_pkg bash-completion | |
install_pkg git | |
install_pkg tree | |
install_pkg vim | |
install_pkg wget | |
install_pkg zsh | |
setup_environment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment