-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep
167 lines (135 loc) · 4.45 KB
/
prep
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
set -e
step() {
echo -e ">> \e[35m$*\e[0m"
}
ok() {
echo -e " \e[32m$*\e[0m"
}
fail() {
echo -e " \e[31m$*\e[0m"
}
installed() {
local bin=$1
local flag=$2
local msg=${3:-$bin}
ok "installed ${msg} ($(${bin} ${flag} 2>&1 | grep -v inflating | head -n1))"
}
github_version() {
local v=${1}
local repo=${2}
if [[ "${v}" == "latest" ]]; then
meta=$(curl -Ls https://api.github.com/repos/${repo}/releases/latest)
tag=$(jq -r .tag_name <(echo "${meta}"))
v=${tag#v}
fi
echo ${v}
}
install_spruce() {
# only works on v1.0.2 or newer
local v=$(github_version ${1} geofffranks/spruce)
curl -LSs -o /usr/local/bin/spruce \
https://github.com/geofffranks/spruce/releases/download/v${v}/spruce-linux-amd64
chmod 0755 /usr/local/bin/spruce
installed spruce -v
}
install_safe() {
local v=$(github_version ${1} starkandwayne/safe)
curl -LSs -o /usr/local/bin/safe \
https://github.com/starkandwayne/safe/releases/download/v${v}/safe-linux-amd64
chmod 0755 /usr/local/bin/safe
installed safe -v
}
install_vault() {
curl -LSs -o /tmp/vault.zip \
https://releases.hashicorp.com/vault/${1}/vault_${1}_linux_amd64.zip
(cd /usr/local/bin ; unzip -qu /tmp/vault.zip ; rm /tmp/vault.zip)
chmod 0755 /usr/local/bin/vault
installed vault -v
}
install_jq() {
curl -LSs -o /usr/local/bin/jq \
https://github.com/stedolan/jq/releases/download/jq-${1}/jq-linux64
chmod 0755 /usr/local/bin/jq
installed jq --version
}
install_genesis() {
local v=$(github_version ${1} starkandwayne/genesis)
curl -LSs -o /usr/local/bin/genesis \
https://github.com/starkandwayne/genesis/releases/download/v${v}/genesis
chmod 0755 /usr/local/bin/genesis
installed genesis -v
}
install_bosh_cli() {
curl -LSs -o /usr/local/bin/bosh https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-${1}-linux-amd64
chmod 0755 /usr/local/bin/bosh
installed bosh -v "BOSH CLI"
}
install_cf_cli() {
curl -LSs "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx
mv cf /usr/local/bin/cf
chmod 0755 /usr/local/bin/cf
installed cf -v "CF CLI"
}
install_sipcalc() {
rm -f /usr/local/bin/sipcalc || true
curl -LSs -o /usr/local/bin/sipcalc \
https://raw.githubusercontent.com/starkandwayne/jumpbox/master/bin/sipcalc
chmod 0755 /usr/local/bin/sipcalc
installed sipcalc -v
}
install_jq ${WANT_JQ_VERSION:-1.5}
install_spruce ${WANT_SPRUCE_VERSION:-latest}
install_safe ${WANT_SAFE_VERSION:-latest}
install_vault ${WANT_VAULT_VERSION:-0.9.6}
install_genesis ${WANT_GENESIS_VERSION:-latest}
install_cf_cli ${WANT_CF_CLI:-6.25}
install_bosh_cli ${WANT_BOSH2_CLI:-3.0.1}
install_sipcalc
cat > $HOME/.bashrc <<'EOF'
export PS1=$(echo -e '\n\e[1;37m\D{%Y.%m.%d} \e[1;33m\D{%H:%M:%S}\e[0m [\e[1;35mark:\e[1;32m${ENV:-(unknown)}\e[0m] \e[1;34m\w\e[0m \n\e[1;32m⠞\e[0m ')
[ -z "$GIT_NAME" ] || git config --global user.name "$GIT_NAME"
[ -z "$GIT_EMAIL" ] || git config --global user.email "$GIT_EMAIL"
git config --global alias.st "status"
git config --global alias.ci "commit"
git config --global alias.cia "commit --amend"
git config --global alias.br "branch"
git config --global alias.co "checkout"
git config --global alias.df "diff"
git config --global alias.dfc "diff --cached"
git config --global alias.dfp "diff --stat -p"
git config --global alias.who "shortlog -s --"
git config --global alias.lg "log -n 20 --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an (via %cn)' --abbrev-commit --date=relative"
git config --global alias.subu "submodule update"
git config --global color.ui auto
git config --global color.diff auto
git config --global color.diff.new "green bold"
git config --global color.diff.old "red bold"
git config --global color.diff.meta "white"
git config --global color.diff.func "magenta bold"
git config --global color.diff.frag "yellow bold"
git config --global color.diff.whitespace "blue reverse"
git config --global color.status.added "green bold"
git config --global color.status.changed "red bold"
git config --global color.status.untracked "cyan bold"
cd /ark
export SHELL=/bin/bash
eval $(dircolors)
alias ls='ls --color'
echo -e '\e[1;32m'
cat <<ARK
### ######## ## ##
## ## ## ## ## ##
## ## ## ## ## ##
## ## ######## #####
######### ## ## ## ##
## ## ## ## ## ##
## ## ## ## ## ##
ARK
echo -e '\e[1;35m'
cat <<ARK
(version 1.0)
ARK
echo -e '\e[0m'
EOF
# vim:ft=bash