Skip to content

Commit

Permalink
Create an installer for these files.
Browse files Browse the repository at this point in the history
- Move from Makefile to install shell script.
- Add support for installing packages.
- Add vagrant bash completion.
- Fix order-of-arguments bug for find on Linux.
  • Loading branch information
conormcd committed Jun 29, 2012
1 parent f96c735 commit 6ce3e09
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule ".vim/bundle/tagbar"]
path = .vim/bundle/tagbar
url = https://github.com/majutsushi/tagbar.git
[submodule "modules/vagrant-bash-completion"]
path = modules/vagrant-bash-completion
url = git://github.com/kura/vagrant-bash-completion.git
2 changes: 1 addition & 1 deletion .tcshrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set path = ( /usr/local/sbin /usr/local/bin /sbin /bin /usr/sbin /usr/bin )
set potential_extra_path_dirs = ( \
/opt/local/sbin \
/opt/local/bin \
`find /usr/local -type d -path '*/texlive/*/bin/x86_64-darwin' -maxdepth 4` \
`find /usr/local -maxdepth 4 -path '*/texlive/*/bin/x86_64-darwin' -type d` \
~/bin \
~/.rvm/bin \
)
Expand Down
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

114 changes: 114 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/sh

set -o errexit
set -o nounset

BREW_TAPS="adamv/alt homebrew/dupes homebrew/versions josegonzalez/php"
OS=$(uname -s)

# Get the full path to the current directory.
cwd=$(pwd)
cd $(dirname $0)
root=$(pwd)
cd ${cwd}

# Symlink a bash completion file
bash_completion() {
completion_file=$1
completion_dir=/etc/bash_completion.d
if which brew > /dev/null 2>&1; then
completion_dir="$(brew --prefix)${completion_dir}"
fi
symlink ${completion_file} ${completion_dir}/$(basename ${completion_file})
}

# Print the command we're going to run and (if DRY_RUN is not set) run it.
cmd() {
echo $*
[ ${DRY_RUN:-unset} = "unset" ] && $*
}

# Ensure a package is installed
pkg() {
for package_name in $*; do
case ${OS} in
(Darwin)
if ! which brew > /dev/null 2>&1; then
cmd ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
for tap in ${BREW_TAPS}; do
if [ "$(brew tap | grep ${tap})" != "${tap}" ]; then
cmd brew tap ${tap}
fi
done
fi
if ! brew list ${package_name} > /dev/null; then
cmd brew install ${package_name}
fi
;;
(Linux)
if [ -f /etc/debian_version ]; then
case ${package_name} in
(ctags)
package_name="exuberant-ctags"
;;
esac
if ! dpkg -s ${package_name} > /dev/null 2>&1; then
cmd sudo aptitude install ${package_name}
fi
else
echo "Unsupported Linux variant."
exit 1
fi
;;
esac
done
}

# Symlink a file from this repo.
symlink() {
file=$1
if [ $# -gt 1 ]; then
target=$2
if [ "$(echo ${target} | grep ^/)" != "${target}" ]; then
target=${HOME}/${target}
fi
else
target=${HOME}/${file}
fi
if [ "$(echo ${file} | grep ^/)" != "${file}" ]; then
file="${root}/${file}"
fi
if [ ! -L ${target} ] || [ $(readlink ${target}) != ${file} ]; then
cmd ln -fns ${file} ${target}
fi
}

#
# Now work through all the things we need.
#

# Install the packages we need
pkg bash bash-completion ctags git nmap vim wget
[ ${OS} = "Darwin" ] && pkg hub nginx php ruby
[ ${OS} != "Darwin" ] && pkg mutt

# Generate .gitconfig
sed -e s/___EMAIL___/$(git config user.email || echo conor@mcdermottroe.com)/ ${root}/.gitconfig.template > ${root}/.gitconfig

# Now link in the dotfiles
symlink .bash_login
symlink .bashrc
symlink .gitconfig
symlink .inputrc
[ ${OS} != "Darwin" ] && symlink .muttrc
symlink .tcsh
symlink .tcshrc
symlink .vim
symlink .vimrc

# Extra bash completions
bash_completion modules/vagrant-bash-completion/vagrant

# Sort out the bin directory
[ -d ${HOME}/bin ] || cmd mkdir ${HOME}/bin
symlink modules/git-wip/git-wip bin/git-wip
1 change: 1 addition & 0 deletions modules/vagrant-bash-completion
Submodule vagrant-bash-completion added at dc1dd6

0 comments on commit 6ce3e09

Please sign in to comment.