-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
190 lines (172 loc) · 4.83 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
#
# radia_run home
#
# curl radia.run | bash -s home
#
# See https://github.com/radiasoft/download for development
#
#
set -euo pipefail
if [[ -r "$HOME"/.pre_bivio_bashrc ]]; then
set +euo pipefail
source "$HOME"/.pre_bivio_bashrc
set -euo pipefail
fi
#POSIT: duplicate code in zz-10-base.sh
if [[ ! ${BIVIO_WANT_PERL+x} ]]; then
# See zz-10-base.sh
if [[ ${BIVIO_HTTPD_PORT+x} || ${BIVIO_HOST_NAME+x} ]]; then
export BIVIO_WANT_PERL=1
else
export BIVIO_WANT_PERL=
fi
fi
biviosoftware="$HOME"/src/biviosoftware
is_cygwin=
if [[ $(uname) =~ CYGWIN ]]; then
is_cygwin=1
fi
mkdir -p "$HOME"/bin
mkdir -p "$biviosoftware"
cd "$biviosoftware"
for repo in home-env \
$( [[ $BIVIO_WANT_PERL ]] && echo perl-Bivio javascript-Bivio perl-ProjEx ) \
; do
if [[ -d $repo ]]; then
(
cd "$repo"
git ${bivio_home_env_ignore_git_dir_ownership:+-c 'safe.directory=*'} pull -q
)
else
u=https://github.com/biviosoftware/$repo.git
# For development
if [[ ${home_env_dev:-} && ${install_server:-} =~ 2916 ]]; then
# NOTE: requires install
u=$install_server/biviosoftware/$repo/.git
fi
git clone -q \
${RADIA_RUN_BRANCH_HOME_ENV:+--branch=$RADIA_RUN_BRANCH_HOME_ENV} \
"$u"
fi
done
# Check for dead links from previous install before this install in case
# we moved a file
for f in "$HOME"/.??* "$HOME"/bin/*; do
if [[ -L $f && ! -e $f ]]; then
rm "$f"
fi
done
if [[ $BIVIO_WANT_PERL ]]; then
mkdir -p ../perl
for p in Bivio ProjEx; do
if [[ -L ../perl/$p ]]; then
rm "../perl/$p"
fi
ln -s "../biviosoftware/perl-$p" "../perl/$p"
done
for p in bivio b-env b-sendmail-http; do
if [[ ! -x "$HOME"/bin/$p ]]; then
ln -s "$HOME"/src/biviosoftware/perl-Bivio/Util/"$p" "$HOME"/bin/"$p"
chmod +x "$HOME"/bin/$p
fi
done
fi
cd home-env
# Our file names don't have spaces so ok
for f in $(shopt -s nullglob; echo {bin,dot}/*); do
src=$PWD/$f
if [[ ! $(basename $src) =~ ^[_a-zA-Z][_a-zA-Z0-9-]+$ ]]; then
# probably tilde or backup file
continue
fi
cmd='ln -s'
if [[ $is_cygwin && -r cygwin/$f ]]; then
src=$PWD/cygwin/$f
cmd='cp -a'
fi
if [[ $src =~ bin/ ]]; then
chmod +x "$src"
dst="$HOME"/$f
else
dst="$HOME"/.${f#dot/}
fi
if [[ -e "$dst" ]]; then
if [[ $src =~ dot/inputrc ]]; then
# inputrc was added much later so don't override
continue
fi
if cmp --silent "$dst" "$src"; then
continue
fi
rm -f "$dst.old"
mv "$dst" "$dst.old"
fi
$cmd "$src" "$dst"
done
for f in gitconfig netrc; do
dst="$HOME"/.$f
if [[ -e $dst ]]; then
continue
fi
if [[ -L $dst ]]; then
rm "$dst"
fi
src=$PWD/template/$f
if [[ -r $src ]]; then
echo "Copying template to $dst; YOU NEED TO EDIT IT."
install -m 0600 "$src" "$dst"
fi
done
docker_config="$HOME"/.docker/config.json
if [[ ! -r $docker_config ]]; then
install -d -m 700 "$(dirname "$docker_config")"
install -m 600 $PWD/template/docker-config.json "$docker_config"
fi
cd "$HOME"
# npmrc may contain credentials so need to append
if ! grep -q -s '^color' .npmrc; then
echo 'color = false' >> .npmrc
chmod 600 .npmrc
fi
# append detachKeys if not there
if ! grep -q -s detachKeys "$docker_config"; then
perl -pi -e 's/(?<=^\{)/\n "detachKeys": "ctrl-],q",/' "$docker_config"
fi
if [[ $BIVIO_WANT_PERL ]]; then
if [[ ! -d "$HOME"/btest-mail ]]; then
(
set +euo pipefail
source "$HOME"/.bashrc
# might error out, because we don't have a db yet
bivio dev setup_all
bivio project link_facade_files
true
) >& /dev/null
fi
if [[ ! -d src/biviosoftware/perl-Artisans ]]; then
(
cd src/biviosoftware
git clone -q https://github.com/biviosoftware/perl-Artisans
true
) >& /dev/null
fi
if [[ -d src/biviosoftware/perl-Artisans ]]; then
mkdir -p src/perl
if [[ ! -L src/perl/Artisans ]]; then
ln -s ../biviosoftware/perl-Artisans src/perl/Artisans
fi
(
cd "$HOME"/src/biviosoftware
for f in $(BCONF=$BIVIO_DEFAULT_BCONF bivio release list_projects_sh_except_bivio); do
if [[ ! -d perl-$f ]]; then
echo "Cloning perl-$f"
git clone -q https://github.com/biviosoftware/perl-$f
fi
if [[ ! -L $HOME/src/perl/$f ]]; then
ln -s "../biviosoftware/perl-$f" "$HOME/src/perl/$f"
fi
done
)
fi
fi