-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·145 lines (128 loc) · 3.75 KB
/
update.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
#!/usr/bin/env bash
source ~/.bashrc
link_dir="$HOME/usr/share/"
debug=0
if [ "$1" = "-d" ];then
debug=1
fi
cd "$(dirname "$0")" || exit 1
curdir=$(pwd)
setting_dir="${link_dir}/$(basename "$curdir")"
function execute_check () {
if [ "$debug" -eq 1 ];then
echo
echo "#################################################################"
echo "# $(pwd)"
echo "# $ $*"
echo "#################################################################"
echo
"$@"
elif ! output=$("$@" 2>&1);then
echo "Error at the directory: $(pwd)"
echo "---"
echo "\$ $*"
echo "$output"
fi
}
# Initial installation
if [ ! -d "$setting_dir" ] && [ ! -L "$setting_dir" ];then
mkdir -p "$link_dir"
ln -s "$curdir" "$setting_dir"
fi
# update git
cd "$setting_dir" || exit 1
for dir in dotfiles scripts mac windows private local;do
[ ! -d $dir ] && continue
cd "$dir" || exit 1
if ! git status >&/dev/null;then
cd ../ || exit 1
continue
fi
if [ -d external ];then
for d in external/*;do
cd "$d" || exit 1
if [ "$(git current-branch)" = "master" ];then
execute_check git pull --rebase
fi
cd - > /dev/null || exit 1
done
fi
if [ $dir = private ] || [ $dir = local ];then
update_options=(--nocheck)
else
update_options=()
fi
if [ -d submodules ];then
for d in submodules/*;do
cd "$d" || exit 1
if [ "$(git current-branch)" = "master" ];then
execute_check git update --nocommit "${update_options[@]}"
fi
cd - > /dev/null || exit 1
done
fi
if [ "$(git current-branch)" = "master" ];then
execute_check git update --commit "${update_options[@]}"
fi
if [ -f ./install.sh ];then
execute_check ./install.sh -b ""
fi
cd ../ || exit 1
done
cd "$setting_dir" || exit 1
if [[ "$OSTYPE" =~ darwin ]];then
cd AppleScript || exit 1
if [ "$(git current-branch)" = "master" ];then
execute_check ./osadeall.sh -b ""
execute_check git update
execute_check ./install.sh -b ""
fi
fi
# Update settings
cd "$setting_dir" || exit 1
execute_check git update
execute_check git submodule update
if [[ "$OSTYPE" =~ darwin ]];then
# OS and OS default app update
execute_check /usr/sbin/softwareupdate --install --all --force
# App Store app update (may need to open AppStore.app...?)
execute_check mas upgrade
# Update Rosetta environment
if [[ "$HOSTTYPE" == arm64 ]] || [[ "$HOSTTYPE" == aarch64 ]] ;then
_path_orig="$PATH"
export PATH="/usr/local/bin:$PATH"
execute_check arch -arch x86_64 /usr/local/bin/brew file update
export PATH="$_path_orig"
fi
fi
# brew
if type brew >& /dev/null;then
execute_check brew file update
fi
# update vim plugins by dein
for vi in vim nvim;do
if type $vi >& /dev/null;then
vim_proc=$(pgrep -l -f "$vi -c"|cut -d ' ' -f 1)
if [ -n "$vim_proc" ];then
echo "previous $vi -c is still running, kill it."
kill -kill $vim_proc
fi
execute_check $vi -c "silent call dein#update()|quit"
execute_check $vi -c "silent call dein#recache_runtimepath()|quit"
if [ $vi = "nvim" ];then
# All in one is too many arguments for Vim
execute_check $vi -c "silent call InstallCocExtentions()|quit"
execute_check $vi -c "silent CocUpdate" -c "quit"
fi
fi
done
# Install packages
_pip_install () {
pip3 install -U pip install pynvim autopep8 black pep8 flake8 pyflakes pylint jedi
}
execute_check _pip_install
_npm_install () {
npm i -g textlint
npm i -g textlint-rule-max-ten textlint-rule-spellcheck-tech-word textlint-rule-no-mix-dearu-desumasu textlint-rule-preset-ja-technical-writing textlint-filter-rule-allowlist textlint-rule-preset-ja-spacing textlint-rule-preset-jtf-style textlint-rule-preset-japanese textlint-rule-terminology
}
execute_check _npm_install