2012-04-04 22:42:24 +00:00
#!/usr/bin/env bash
2012-03-29 17:02:14 +00:00
# Environment setup redone in bash, because using call in Python is lame
# Basic requirements - bash, sudo (Also make sure your user has sudo privileges!)
# a die function as always
die( ) {
printf '%s\n' " $@ " >& 2
exit 1
}
# Some variable(s)
2012-06-16 18:40:12 +00:00
userdistro = "NULL"
repo = "git://github.com/staticsafe/dotfiles.git"
2012-03-29 17:02:14 +00:00
2012-06-16 18:41:51 +00:00
portpath = "/opt/local/bin/port" # This is the default install directory for the MacPorts port binary, you may find this useful.
2012-03-30 17:14:05 +00:00
2012-03-29 17:02:14 +00:00
# Lets get this party on the road, shall we?
sudocheck( ) {
hash sudo & >/dev/null || die 'sudo does not exist, exiting'
printf '%s\n' "sudo check : PASSED"
}
distrocheck( ) {
2012-06-16 18:35:31 +00:00
hash apt-get & >/dev/null && userdistro = "Debian" # For Debian based distros.
hash yum & >/dev/null && userdistro = "Fedora" # For RHEL/CentOS/Fedora
hash pacman & >/dev/null && userdistro = "Arch" # For Arch Linux
hash port & >/dev/null && userdistro = "OSX" # For OSX, make sure the port binary is in your PATH first.
hash pkg_add & >/dev/null && userdistro = "FreeBSD" # For FreeBSD
hash equo & >/dev/null && userdistro = "Sabayon" # For Sabayon
2012-06-16 18:54:15 +00:00
hash emerge & >/dev/null && hash equo & >/dev/null || userdistro = "Gentoo" # For Gentoo
2012-03-29 17:02:14 +00:00
}
installpackages( ) {
if [ [ " $userdistro " = = "Debian" ] ] ; then
2012-06-10 21:56:31 +00:00
sudo apt-get install --assume-yes vim zsh tmux git subversion mercurial most python-pip
2012-03-29 17:02:14 +00:00
elif [ [ " $userdistro " = = "Fedora" ] ] ; then
2012-06-10 21:56:31 +00:00
sudo yum install -y vim zsh tmux git subversion mercurial most python-pip
2012-03-29 17:02:14 +00:00
elif [ [ " $userdistro " = = "Arch" ] ] ; then
2012-06-10 21:56:31 +00:00
sudo pacman --no-confirm -S vim zsh tmux git mercurial subversion most python-pip
2012-03-30 17:14:05 +00:00
elif [ [ " $userdistro " = = "OSX" ] ] ; then
2012-06-10 21:56:31 +00:00
sudo port install vim zsh tmux git-core git-extras mercurial subversion most
2012-03-30 17:14:05 +00:00
#echo "export PATH=/opt/local/bin:/opt/local/sbin:$PATH" >> ~/.zshenv # This adds the port binary path, so that zsh can use it after, commented out by default.
2012-04-18 01:25:02 +00:00
elif [ [ " $userdistro " = = "FreeBSD" && $( uname -s) = = "FreeBSD" ] ] ; then
2012-06-10 21:56:31 +00:00
sudo pkg_add -r vim zsh tmux git subversion mercurial most py27-pip
elif [ [ " $userdistro " = = "Sabayon" ] ] ; then
sudo equo install vim zsh tmux git subversion mercurial most python-pip
2012-06-16 18:27:05 +00:00
elif [ [ " $userdistro " = = "Gentoo" ] ] ; then
sudo emerge vim zsh tmux git subversion mercurial most python
2012-03-29 17:02:14 +00:00
else
die 'Your distro does not have a package manager supported by this script, exiting!'
fi
}
changeshell( ) {
if [ [ $SHELL = = "/usr/bin/zsh" || $SHELL = = "/bin/zsh" ] ] ; then
printf '%s\n' "Your default shell is already zsh, continuing."
else
chsh -s $( which zsh)
2012-03-29 17:19:13 +00:00
printf '%s\n' "Default shell changed to zsh, logout and login to see changes"
2012-03-29 17:02:14 +00:00
fi
}
linkfiles( ) {
2012-03-29 17:19:13 +00:00
#find ~/dev/dotfiles -type f -name ".*" -execdir ln -s -f {}
# --target-directory=$HOME \; # removed until I can figure out the issue
ln -sf ~/dev/dotfiles/.zshrc $HOME /
ln -sf ~/dev/dotfiles/.vimrc $HOME /
ln -sf ~/dev/dotfiles/.tmux.conf $HOME /
ln -sf ~/dev/dotfiles/.conkyrc $HOME /
ln -sf ~/dev/dotfiles/.zsh $HOME /
ln -sf ~/dev/dotfiles/.vim $HOME /
2012-03-29 17:02:14 +00:00
touch ~/.zhistory
}
getdotfiles( ) {
if [ [ -d ~/dev/dotfiles ] ] ; then
cd ~/dev/dotfiles
git pull
linkfiles
else
mkdir ~/dev
cd ~/dev
git clone $repo
linkfiles
fi
}
sudocheck
distrocheck
installpackages
changeshell
getdotfiles
2012-04-10 17:05:44 +00:00
exec zsh