-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·68 lines (51 loc) · 1.13 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
#!/bin/bash
set -e
main() {
readonly dotfile_dir="$HOME/.dotfiles"
download
execute
}
download() {
local repository="git@github.com:yudoufu/dotfiles.git"
local tarball="https://github.com/yudoufu/dotfiles/archive/master.tar.gz"
if has_git; then
if [ -d "$dotfile_dir" ]; then
cd "$dotfile_dir"
git pull
git submodule update --init
git submodule foreach 'git checkout master; git pull'
else
git clone --recursive "$repository" "$dotfile_dir"
fi
elif has_curl || has_wget; then
if has_curl; then
curl -L "$tarball"
elif has_wget; then
wget -O - "$tarball"
fi | tar xz
if [ ! -d "dotfiles-master" ]; then
echo "dotfiles-master doesn't exist." >&2
exit 1
fi
mv -f "dotfiles-master" "$dotfile_dir"
else
echo "Don't exist download tools. Please install git or curl/wget."
exit 1
fi
}
execute() {
/bin/bash "$dotfile_dir/etc/setup.sh"
}
has_git() {
return $(has_cmd "git")
}
has_curl() {
return $(has_cmd "curl")
}
has_wget() {
return $(has_cmd "wget")
}
has_cmd() {
return $(type "$@" > /dev/null 2>&1)
}
main "$@"