-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.sh
executable file
·109 lines (88 loc) · 2.62 KB
/
setup.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
#!/bin/sh
Color_Purple='\033[0;35m' # Purple
Color_Off='\033[0m' # Reset
msg() {
printf "%b\n" "$1"
}
info() {
msg "${Color_Purple}[❉]${Color_Off} $1$2"
}
installOhMyFish() {
info "Installing oh-my-fish..."
curl -L https://get.oh-my.fish | fish
}
checkDependencies() {
info "CheckDependencies"
if command -v emerge > /dev/null ; then
command -v git > /dev/null || pkgNames="$pkgNames dev-vcs/git"
else
command -v git > /dev/null || pkgNames="$pkgNames git"
fi
command -v curl > /dev/null || pkgNames="curl"
command -v git > /dev/null || pkgNames="$pkgNames git"
command -v fish > /dev/null || pkgNames="$pkgNames fish"
command -v which > /dev/null || pkgNames="$pkgNames which"
}
installDependencies() {
info "InstallDependencies $pkgNames"
sudo=$(command -v sudo 2> /dev/null)
osType=$(uname -s)
if [ "$osType" = "Linux" ] ; then
# Gentoo、Funtoo
command -v emerge > /dev/null && {
$sudo emerge $@
return $?
}
# ArchLinux、ManjaroLinux
command -v pacman > /dev/null && {
$sudo pacman -Syyuu --noconfirm &&
$sudo pacman -S --noconfirm $@
return $?
}
# Debian GNU/Linux系
command -v apt-get > /dev/null && {
$sudo apt-get -y update &&
$sudo apt-get -y install $@
return $?
}
# Fedora、CentOS8
command -v dnf > /dev/null && {
$sudo dnf -y update &&
$sudo dnf -y install $@
return $?
}
# CentOS7、6
command -v yum > /dev/null && {
$sudo yum -y update &&
(command -v fish > /dev/null || $sudo yum -y install epel-release) &&
$sudo yum -y install $@
return $?
}
# OpenSUSE
command -v zypper > /dev/null && {
$sudo zypper update -y &&
$sudo zypper install -y $@
return $?
}
# AlpineLinux
command -v apk > /dev/null && {
$sudo apk update &&
$sudo apk add $@
return $?
}
elif [ "$osType" = "Darwin" ] ; then
if command -v brew > /dev/null ; then
brew update
else
printf "\n" | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew install $@
return $?
fi
}
main() {
checkDependencies
[ -z "$pkgNames" ] || installDependencies "$pkgNames"
installOhMyFish
}
main