-
Notifications
You must be signed in to change notification settings - Fork 32
/
deploy.sh
executable file
·82 lines (69 loc) · 2.18 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
76
77
78
79
80
81
82
#!/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 == Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo == Link configurations files not overwriting existing regular files
cd configs
for f in $(find -type f -printf '%P\n' | grep -v rbenv); do
DIR=$HOME/$(dirname $f)
[[ -L $DIR && $opt_overwrite ]] && rm $DIR
mkdir -p $DIR
DEST=$HOME/$f
echo "$PWD/$f -> $DEST"
[[ $opt_overwrite ]] && rm $DEST
ln -sf $PWD/$f $DEST
done
cd -
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