-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·95 lines (81 loc) · 1.95 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
#!/bin/bash
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
check_installed(){
echo 'Check for' $1
if command -v $1 &> /dev/null; then
echo $1 'installed'
return 0
else
echo $1 'not installed'
return 1
fi
}
install_package(){
for package in $@; do
if ! check_installed $package; then
echo 'Installing' $package
exec $(install_str) $package
fi
done
}
install_str(){
if [[ $platform == 'debian' ]]; then
echo 'sudo apt-get install'
elif [[ $platform == 'macos' ]]; then
echo 'brew install'
fi
}
install_curl(){
if [[ $platform == 'debian' ]]; then
check_installed 'curl' || sudo apt-get install curl
elif [[ $platform == 'macos' ]]; then
check_installed 'curl' || \
{ echo 'curl should come with macos' && \
\
return 1; }
fi
}
install_package_manager(){
if [[ $platform == 'debian' ]]; then
echo 'debian comes with apt-get'
elif [[ $platform == 'macos' ]]; then
echo 'Installing package manager'
check_installed 'brew' || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
install_zsh(){
install_package zsh
if [[ $platform == 'debian' ]]; then
chsh -s /usr/local/bin/zsh
elif [[ $platform == 'macos' ]]; then
chsh -s $(brew --prefix)/bin/zsh; \
fi
}
unknown='unknown'
# get the platform
platform=$unknown
os_version=$unknown
arch=$unknown
osname=$(lowercase $(uname))
kernel=$(uname -r)
mach=$(uname -m)
version=$(lowercase $(uname -v))
case $osname in
'linux')
platform='linux'
case $version in
*'ubuntu'*)
platform='debian'
;;
esac
;;
'darwin')
platform='macos'
;;
esac
echo 'platform' $platform
install_curl
install_package_manager
install_zsh