2014-04-14 21:49:44 -06:00
|
|
|
#!/usr/bin/env bash
|
2014-08-25 20:10:05 -06:00
|
|
|
cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh
|
|
|
|
source dotfiles/lib/shellrc/functions.sh
|
|
|
|
source dotfiles/lib/shellrc/brew.sh
|
|
|
|
source dotfiles/lib/shellrc/python.sh
|
2014-08-25 21:18:08 -06:00
|
|
|
source dotfiles/lib/shellrc/vim.sh
|
2014-08-25 20:10:05 -06:00
|
|
|
DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles"
|
|
|
|
|
|
|
|
|
|
|
|
function symlink_dotfiles() {
|
2014-08-25 21:06:54 -06:00
|
|
|
local overwrite=''
|
|
|
|
OPTIND=1
|
|
|
|
while getopts "o" OPTCHAR;
|
|
|
|
do
|
|
|
|
case $OPTCHAR in
|
|
|
|
o)
|
|
|
|
overwrite='yes'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2014-08-25 20:10:05 -06:00
|
|
|
cd $DOTFILES_DIRECTORY
|
|
|
|
[ -a ~/.dotfiles-backups ] && mv ~/.dotfiles-backups ~/.dotfiles-backups.old
|
|
|
|
mkdir ~/.dotfiles-backups
|
|
|
|
for filename in *; do
|
|
|
|
local link_destination="$HOME/.$filename"
|
|
|
|
local link_target=$(${readlink_command} -f $filename)
|
|
|
|
echo "linking $link_destination to $link_target"
|
|
|
|
# Using only test -e doesn't work here because it will return
|
|
|
|
# false if the destination of the symbolic link at does not exist.
|
2014-08-25 21:06:54 -06:00
|
|
|
test -e $link_destination || test -L $link_destination && test $overwrite && mv $link_destination ~/.dotfiles-backups && ln -si $link_target $link_destination
|
2014-08-25 20:10:05 -06:00
|
|
|
done
|
|
|
|
[ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups
|
|
|
|
}
|
2014-05-02 15:11:27 -06:00
|
|
|
|
|
|
|
|
2014-08-25 20:10:05 -06:00
|
|
|
function symlink_dotfiles_prompt() {
|
2014-08-25 21:06:54 -06:00
|
|
|
read -p "Symlinking files from $DOTFILES_DIRECTORY. This ? (y/n) " -n 1
|
2014-08-25 20:10:05 -06:00
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
|
echo
|
|
|
|
symlink_dotfiles
|
|
|
|
fi
|
2014-08-25 18:06:42 -06:00
|
|
|
}
|
2013-03-18 10:56:29 -06:00
|
|
|
|
2014-08-25 21:06:54 -06:00
|
|
|
function apt-get() {
|
|
|
|
INSTALL="sudo apt-get -y install"
|
|
|
|
$INSTALL zsh
|
|
|
|
$INSTALL tmux
|
|
|
|
$INSTALL emacs24-nox
|
|
|
|
$INSTALL nmap
|
|
|
|
$INSTALL python2.7
|
|
|
|
$INSTALL python-pip python-dev
|
|
|
|
}
|
|
|
|
|
2014-08-25 20:10:05 -06:00
|
|
|
function setup_help() {
|
|
|
|
echo "setup Usage:
|
|
|
|
-a Install apt-get packages.
|
|
|
|
-o Run OSX configuration commands.
|
|
|
|
-s Symlink dotfiles to home directory.
|
|
|
|
-b Install brew packages.
|
|
|
|
-p Install python packages.
|
2014-08-25 21:18:08 -06:00
|
|
|
-v Setup vim.
|
2014-08-25 21:06:54 -06:00
|
|
|
-e Do absolutely everything with the most aggresive options.
|
2014-08-25 20:10:05 -06:00
|
|
|
-h display this help message."
|
|
|
|
}
|
2014-05-02 15:11:27 -06:00
|
|
|
|
2014-08-25 20:10:05 -06:00
|
|
|
function setup() {
|
|
|
|
if [[ $# -eq 0 ]] ; then
|
|
|
|
setup_help
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-08-25 21:18:08 -06:00
|
|
|
while getopts "aosbpev" OPTCHAR;
|
2014-08-25 18:06:42 -06:00
|
|
|
do
|
|
|
|
case $OPTCHAR in
|
2014-08-25 20:10:05 -06:00
|
|
|
a)
|
|
|
|
source resources/apt-get.sh
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
do_the_brew_help
|
|
|
|
read -p "Enter flags for brew package installation:
|
|
|
|
"
|
|
|
|
[[ $REPLY[0] != '-' ]] && REPLY="-$REPLY"
|
|
|
|
do_the_brew $REPLY
|
|
|
|
;;
|
|
|
|
o)
|
|
|
|
sudo -v
|
|
|
|
source resources/osx.sh
|
|
|
|
;;
|
|
|
|
s)
|
|
|
|
symlink_dotfiles_prompt
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
install_python_packages -h
|
|
|
|
read -p "Enter flags for python package installation"
|
|
|
|
if [[ $REPLY[0] != '-' ]]; then
|
|
|
|
REPLY="-$REPLY"
|
|
|
|
fi
|
|
|
|
install_python_packages $REPLY
|
|
|
|
;;
|
2014-08-25 21:06:54 -06:00
|
|
|
e)
|
|
|
|
case uname in
|
|
|
|
Darwin)
|
|
|
|
do_the_brew -au
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
apt-get
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
install_python_packages -a
|
|
|
|
symlink_dotfiles
|
|
|
|
source resources/osx.sh
|
2014-08-25 21:18:08 -06:00
|
|
|
vimstall
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
vimstall
|
2014-08-25 21:06:54 -06:00
|
|
|
;;
|
2014-08-25 18:06:42 -06:00
|
|
|
h)
|
2014-08-25 20:10:05 -06:00
|
|
|
setup_help
|
|
|
|
return
|
2014-08-25 18:06:42 -06:00
|
|
|
;;
|
2014-08-25 20:10:05 -06:00
|
|
|
esac
|
|
|
|
done
|
2014-05-02 15:11:27 -06:00
|
|
|
}
|
2014-08-25 20:10:05 -06:00
|
|
|
|
|
|
|
setup $@
|