-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploying_locally.sh
279 lines (248 loc) · 9.81 KB
/
deploying_locally.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# set git connect method
git_method=${1:-'https'}
if [ $git_method == 'https' ]; then
url_root="https://github.com/"
elif [ $git_method == 'ssh' ]; then
url_root="[email protected]:"
else
echo "git_method must be one of <https|ssh>"
fi
echo "set git connect method: $git_method (https (default) / ssh)"
# get repo path
REPO_PATH=$(pwd)
chmod +x $REPO_PATH/bin/mse_update
# ------------------------------------------------------------------->>>>>>>>>>
# platform judgement and var setting
# ------------------------------------------------------------------->>>>>>>>>>
platform="$(uname)"
platform=$(echo $platform | awk -F '_' '{printf $1}')
if [[ "$platform" == "Linux" ]]; then
platform="Linux"
URL=https://micro.mamba.pm/api/micromamba/linux-64/latest
ROOT_PATH=$HOME/0.apps/micromamba
elif [[ "$platform" == "Darwin" ]]; then
if [[ "$(uname -p)" == "i386" ]]; then
platform="MacOS/x86_64"
URL=https://micro.mamba.pm/api/micromamba/osx-64/latest
ROOT_PATH=$HOME/micromamba
elif [[ "$(uname -p)" == "arm" ]]; then
platform="MacOS/arm64"
URL=https://micro.mamba.pm/api/micromamba/osx-arm64/latest
ROOT_PATH=$HOME/micromamba
fi
elif [[ "$platform" == "MINGW64" ]]; then
platform="Windows" # TODO, no strategy now
else
echo "unsupported OS: $platform!"
exit 1
fi
echo -e "---------------------------------|\nplatform detected: $platform"
# ------------------------------------------------------------------->>>>>>>>>>
# micromamba setting (annotate if not use)
# ------------------------------------------------------------------->>>>>>>>>>
CONDA_ENVS=$REPO_PATH/conda_local_env_settings
if [[ "$platform" != "Windows" ]]; then
echo -e "---------------------------------|\nset conda env config files..."
# install micromamba
if [ ! -f "$ROOT_PATH/bin/micromamba" ]; then
echo "micromamba not found @$ROOT_PATH/bin/! start to install..."
if [ -z "$(which bzip2)" ]; then
echo "Seems the command 'bzip2' is not installed on your system, please install it first."
exit 1
fi
mkdir -p $ROOT_PATH
cd $ROOT_PATH
curl -Ls $URL | tar -xvj bin/micromamba
cd $REPO_PATH
# this repo fix pycharm conda, select conda/micromamba-pycharm/conda when using conda in pycharm!
git clone ${url_root}jonashaag/micromamba-pycharm.git conda/micromamba-pycharm
else
echo "micromamba exists @$ROOT_PATH/bin/! skip installing..."
fi
# set yml files...
echo "start to choose env.yml..."
# make softlink directory
mkdir -p $CONDA_ENVS
for yml in $(ls $REPO_PATH/conda/$platform/*.yml); do
ln -sf $yml $CONDA_ENVS/$(basename $yml)
done
echo "conda config files @: $CONDA_ENVS "
else
echo "skip micromamba installing:" $platform
fi
echo "set micromamba as conda / mamba successful"
echo -e "---------------------------------|\nset conda panels..."
mv $HOME/.condarc $HOME/.condarc_bak
ln -s $REPO_PATH/conda/condarc $HOME/.condarc
echo "set condarc successful"
# ------------------------------------------------------------------->>>>>>>>>>
# zsh setting (annotate if not use)
# ------------------------------------------------------------------->>>>>>>>>>
if [[ "$platform" != "Windows" ]]; then
echo -e "---------------------------------|\nset zsh config file"
platform_fix="$(echo $platform | awk -F '/' '{printf $1}')" # fix "MacOS/x86_64" or "MacOS/arm64" to "MacOS"
/bin/rm -rf $HOME/.zshrc_bak 2>/dev/null
mv $HOME/.zshrc $HOME/.zshrc_bak
ln -s $REPO_PATH/zsh/zshrc $HOME/.zshrc
echo "zsh config file @: $REPO_PATH/zsh/zshrc"
else
echo "zsh not support platform:" $platform
fi
echo "set zsh config (zshrc) successful"
# ------------------------------------------------------------------->>>>>>>>>>
# spyder setting (annotate if not use)
# ------------------------------------------------------------------->>>>>>>>>>
echo -e "---------------------------------|\nset spyder config file"
platform_fix="$(echo $platform | awk -F '/' '{printf $1}')" # fix "MacOS/x86_64" or "MacOS/arm64" to "MacOS"
/bin/rm -rf $HOME/.spyder-py3_bak 2>/dev/null
mv $HOME/.spyder-py3 $HOME/.spyder-py3_bak
ln -s $REPO_PATH/spyder/general/spyder-py3 $HOME/.spyder-py3
echo "spyder config file @: $REPO_PATH/spyder/general/spyder-py3"
echo "set spyder config successful"
# ------------------------------------------------------------------->>>>>>>>>>
# pip settings (annotate if not use)
# ___________________________________________________________________>>>>>>>>>>
echo -e "---------------------------------|\nset pip config file"
mkdir -p $HOME/.pip
/bin/rm -rf $HOME/.pip/pip.conf_bak 2>/dev/null
mv $HOME/.pip/pip.conf $HOME/.pip/pip.conf_bak
ln -s $REPO_PATH/pip/pip.conf $HOME/.pip/pip.conf
echo "pip config file @: $REPO_PATH/pip/pip.conf"
echo "set pip config successful"
# ------------------------------------------------------------------->>>>>>>>>>
# vim/nvim setting (annotate if not use)
# ------------------------------------------------------------------->>>>>>>>>>
echo -e "---------------------------------|\nset vim config file"
if test -e $HOME/.vim/vimrc; then
echo 'old setting exists, running update steps...'
cd $HOME/.vim
git fetch
git pull
else
echo 'old setting does not exist, running git clone steps...'
cd $HOME
mv .vim .vimbak &>/dev/null
mv .vimrc .vimrcbak &>/dev/null
git clone ${url_root}hermanzhaozzzz/vim-for-coding.git $HOME/.vim
ln -s .vim/vimrc .vimrc
echo "vim config file @ $HOME/.vim"
fi
echo "set vim successful"
echo -e "---------------------------------|\nset nvim config file"
if test -e $HOME/.config/nvim/init.lua; then
echo 'old setting exists, running update steps...'
cd $HOME/.config/nvim
git fetch
git pull
else
echo 'old setting does not exist, running git clone steps...'
/bin/rm -rf ~/.cache/nvim ~/.local/share/nvim 2>/dev/null
git clone ${url_root}ayamir/nvimdots.git $HOME/.config/nvim
echo "nvim config file @ $HOME/.config/nvim"
fi
echo "set nvim successful"
# # ------------------------------------------------------------------->>>>>>>>>>
# # kitty setting (annotate if not use)
# # ------------------------------------------------------------------->>>>>>>>>>
# echo -e "---------------------------------|\nset kitty config file"
# mkdir -p $HOME/.config/kitty
# mv $HOME/.config/kitty $HOME/.config/kitty_bak
# ln -s $REPO_PATH/tools/kitty $HOME/.config/kitty
# echo "set kitty successful"
# ------------------------------------------------------------------->>>>>>>>>>
# set external apps
# ------------------------------------------------------------------->>>>>>>>>>
echo -e "---------------------------------|\nset external tools...\n"
# jcat
echo "set jcat"
if [[ "$platform" != "Windows" ]]; then
if test -e $REPO_PATH/tools/jcat/jcat; then
echo 'old setting exists, nothing to do...'
else
echo 'old setting does not exist, running jcat compiling steps...'
mkdir -p $REPO_PATH/bin
/bin/rm $REPO_PATH/bin/jcat 2>/dev/null
/bin/rm $REPO_PATH/tools/jcat/jcat 2>/dev/null
cd $REPO_PATH/tools/jcat
if [ -z $(which make) ]; then
echo "Seems the command 'make' is not installed on your system, please install it first."
exit 1
fi
make
ln -s $REPO_PATH/tools/jcat/jcat $REPO_PATH/bin/jcat
fi
echo "set jcat successful"
else
echo "jcat not support platform:" $platform
fi
# wudao dict
echo "set wd"
if test -e $HOME/.Wudao-dict/wudao-dict/wd; then
echo 'old setting exists, running update steps...'
cd $HOME/.Wudao-dict
git fetch
git pull
else
echo 'old setting does not exist, running git clone steps...'
git clone ${url_root}hermanzhaozzzz/Wudao-dict.git $HOME/.Wudao-dict
cd $HOME/.Wudao-dict/wudao-dict
mkdir ./usr
chmod -R 777 ./usr
pip install bs4 lxml
echo '#!/bin/bash' >./wd
echo 'save_path=$PWD' >>./wd
echo 'cd '$PWD >>./wd
echo './wdd $*' >>./wd
echo 'cd $save_path' >>./wd
chmod +x ./wd
ln -s $HOME/.Wudao-dict/wudao-dict/wd $REPO_PATH/bin/wd
fi
echo "set wd successful"
# tldr
echo "set tldr"
if test -e $REPO_PATH/bin/tldr; then
echo 'old setting exists, nothing to do...'
else
/bin/rm ~/.my_shell_envs/bin/tldr 2>/dev/null
ln -s $ROOT_PATH/bin/tldr ~/.my_shell_envs/bin/tldr
fi
echo "set tldr successful"
# ------------------------------------------------------------------->>>>>>>>>>
# Windows setting for PowerShell (dependent: git-bash)
# ------------------------------------------------------------------->>>>>>>>>>
if [[ "$platform" == "Windows" ]]; then
cd $REPO_PATH
WinProfile="$HOME/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"
RepoProfile="$REPO_PATH/powershell/Microsoft.PowerShell_profile.ps1"
echo -e "---------------------------------|\nset profile softlink @ $WinProfile..."
/bin/rm -rf $HOME/.condarc 2>/dev/null
powershell -File $RepoProfile
mv $WinProfile ${WinProfile}_bak
ln -s $RepoProfile $WinProfile
echo "profile config file @ $RepoProfile"
# end
echo -e "---------------------------------|\nall done"
echo "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"
echo -e "well done there! now you should:\n"
echo -e "\t\topen PowerShell to use your environment, something will be installed at the first running!"
echo -e "\t\tconda activate base"
echo -e "\t\tconda install -f $CONDA_ENVS/base.yml # in powershell!"
echo "and start to use this environment."
echo "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
echo "this window will close after 300s, you can exit now."
echo "ヾ(≧O≦)〃~"
sleep 300
else
# end
echo -e "---------------------------------|\nall done"
echo "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"
echo -e "well done there! now you should:\n"
echo -e "\t\tsource ~/.zshrc"
echo -e "\t\tconda activate base"
echo -e "\t\tconda install -f $CONDA_ENVS/base.yml"
echo "and start to use this environment."
echo "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
echo "ヾ(≧O≦)〃~"
fi
echo "Tips:"
echo -e "\t raise issue on https://github.com/hermanzhaozzzz/.my_shell_envs/issues"