forked from brauliobo/gitconfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·75 lines (64 loc) · 2.1 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# from http://stackoverflow.com/questions/9271381/how-can-i-parse-long-form-arguments-in-shell
_setArgs() {
while [ "$1" != "" ]; do
case $1 in "-o" | "--overwrite")
opt_overwrite=$1
;;
esac
case $1 in "-v" | "--verbose")
opt_verbose=$1
;;
esac
shift
done
}
_setArgs $*
test $opt_verbose && set -x
echo == Link configurations files not overwriting existing regular files
for f in `ls -A configs | grep -v '^\.config$'`; do
[[ -L $HOME/$f || $opt_overwrite ]] && rm $HOME/$f
ln -ns $PWD/configs/$f $HOME/$f
done
for f in `ls -A configs/.config`; do
[[ -L $HOME/.config/$f || $opt_overwrite ]] && rm $HOME/$f
ln -ns $PWD/configs/.config/$f $HOME/.config/$f
done
while [ -h "$SOURCE" ]; do SOURCE="$(readlink "$SOURCE")"; done
GITROOT="$(builtin cd -P "$(dirname "$SOURCE")" && git root)"
echo == Source $GITROOT/default/config
source $GITROOT/default/config
echo == Update submodules
git smuir --quiet
echo == Setup rbenv
ln -nsf $GITROOT/src/rbenv-plugins $GITROOT/configs/.rbenv/plugins
#echo == Install Oh my ZSH
#if [[ ! -x $HOME/.oh-my-zsh ]]; then
# wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
#fi
if [[ $RUBY_FROM == 'rvm' ]]; then
echo == Install RVM
if [[ ! -x $HOME/.rvm ]]; then
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -#L https://get.rvm.io | bash -s stable
fi
fi
echo == Add autoload configs code
if ! grep zshmine.sh $HOME/.zshrc > /dev/null; then
echo '. $HOME/.zshmine.sh' >> ~/.zshrc
fi
if ! grep bashmine.sh $HOME/.bashrc > /dev/null; then
echo '. $HOME/.bashmine.sh' >> ~/.bashrc
echo '. $HOME/.bashmine.sh' >> ~/.bash_profile
fi
echo == Grab gems credentials
if [[ -n "$RUBYGEMS_USER" && ! -f ~/.gem/credentials ]]; then
mkdir -p ~/.gem
curl -u $RUBYGEMS_USER https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
chmod 0600 /home/braulio/.gem/credentials
fi
echo == Install hooks
find -L .git/hooks -type f ! '(' -name '*.sample' ')' -delete
for h in `ls $GITROOT/hooks`; do
ln -nsf $GITROOT/hooks/$h $GITROOT/.git/hooks
done