-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·120 lines (99 loc) · 2.85 KB
/
install.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
DOTFILES_ROOT=$(pwd -P)
set -e
echo ''
info () {
printf "\r $1\n"
}
success () {
printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n"
}
fail () {
printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n"
echo ''
exit
}
backup(){
local dst=$1
if [ -f "$dst" -o -d "$dst" -o -L "$dst" ]
then
cp "$dst" "${dst}.backup"
success "backuped $dst to ${dst}.backup"
fi
}
symlink(){
# Force create/replace the symlink.
ln -fs $1 $2
success "linked $1 to $2"
}
copy(){
# Force copy
cp $1 $2
success "copied $1 to $2"
}
install_cf_plugin(){
cf install-plugin -r CF-Community -f "$1" > /dev/null
success "installed CF plugin $1"
}
install_npms(){
npm install -g $1 > /dev/null
success "installed $1 globally"
}
install_nvm(){
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"
reload_bashrc
nvm install node
nvm install-latest-npm
}
copy_bin(){
[[ -d "${HOME}/bin" ]] || mkdir "${HOME}/bin"
cp -fr "${DOTFILES_ROOT}/bin" "${HOME}"
find "${HOME}/bin" -type f -exec chmod +x {} \;
success "bin folder is copied"
}
reload_bashrc(){
source ${HOME}/.bashrc
success "bashrc is reloaded"
}
check_prereq(){
info "checking prerequisites"
if ! [ -x "$(command -v cf)" ]; then
#normally we would install CF, but sudo is not available in business application studio's integrated terminal
fail "cf is not available, install it and try again"
exit 1
fi
if ! [ -x "$(command -v node)" ]; then
#normally we would install Node, but sudo is not available in business application studio's integrated terminal
fail "node is not available, install it and try again"
exit 1
fi
}
info "📦 creating backup"
backup "${HOME}/.bashrc"
backup "${HOME}/.gitconfig"
backup "${HOME}/.theia/settings.json"
backup "${HOME}/.theia/keymaps.json"
info "📦 copying dot files"
copy "${DOTFILES_ROOT}/bashrc" "${HOME}/.bashrc"
copy "${DOTFILES_ROOT}/gitconfig" "${HOME}/.gitconfig"
copy "${DOTFILES_ROOT}/git-completion.bash" "${HOME}/.git-completion.bash"
info "📦 copying bins"
copy_bin
info "📦 copying business application studio files"
[[ -d "${HOME}/.theia" ]] || mkdir "${HOME}/.theia"
copy "${DOTFILES_ROOT}/theia/settings.json" "${HOME}/.theia"
copy "${DOTFILES_ROOT}/theia/keymaps.json" "${HOME}/.theia"
info "📦 installing CF plugins"
install_cf_plugin "open"
install_cf_plugin "check-before-deploy"
install_cf_plugin "html5-plugin"
install_cf_plugin "service-management"
# install cf plugin not from CF repo
cf install-plugin https://github.com/saphanaacademy/DefaultEnv/releases/download/v1.0.0/DefaultEnv.linux32 -f > /dev/null
success "installed CF plugin DefaultEnv"
echo ''
info '🧢🧢🧢 All installed! 🧢🧢🧢'