-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·61 lines (51 loc) · 1.74 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
#!/bin/bash
source ./functions.sh
check_package_tool() {
if ! command_exists $1; then
echo -e "${ERROR}Package Manager ${MAGENTA}${1}${NC} not found"
exit 1
fi
}
if [ $useful_package = 'y' ]; then
package_name="useful-packages"
echo -e "${INFO}Install/Upgrade ${package_name} config..."
packages=("aria2" "bat" "eza" "fd" "fzf" "plocate" "ripgrep" "thefuck" "tmux" "zoxide")
shopt -s nocasematch
package_tool=""
pkg_install_cmd=""
# Change the package name to correspond to the relative OS
for (( i=0; i<${#packages[@]}; i++ )); do
if [[ $platform =~ ("debian"|"ubuntu"|"kali") ]]; then
package_tool="apt"
pkg_install_cmd="sudo ${package_tool} install -qq -y"
if [[ ${packages[i]} == "fd" ]]; then
packages[i]="fd-find"
fi
elif [[ $platform =~ "arch" ]]; then
package_tool="pacman"
pkg_install_cmd="sudo ${package_tool} -S"
elif [[ $platform =~ "darwin" ]]; then
package_tool="brew"
check_package_tool $package_tool
pkg_install_cmd="${package_tool} install --quiet"
else
echo -e "${ERROR}your OS type not support yet install package script"
exit 1
fi
done
all_package=${packages[@]}
echo -e "${BLUE}package list: ${GREEN}${all_package}${NC}"
cmd="${pkg_install_cmd} ${all_package}"
echo -e "${MAGENTA}${cmd}${NC}"
eval $cmd
cmd="sudo updatedb"
echo -e "${MAGENTA}${cmd}${NC}"
eval $cmd
if [ $? -ne 0 ]; then
echo -e "${ERROR}command ${MAGENTA}${cmd}${NC} failed"
exit 1
else
echo -e "${INFO}Install/Upgrade useful-packages successful"
fi
exit 0
fi