-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall-tools.sh
139 lines (121 loc) · 3.63 KB
/
install-tools.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
#!/usr/bin/env bash
#colors
NONE='\033[00m'
RED='\033[01;31m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
PURPLE='\033[01;35m'
CYAN='\033[01;36m'
WHITE='\033[01;37m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
echo -e "${RED}${BOLD}______ __ _ _ _ _ _____ _ ${NONE}"
echo -e "${RED}${BOLD}| _ \ / _| | | | | | (_) |_ _| | | ${NONE}"
echo -e "${RED}${BOLD}| | | |___| |_ __ _ _ _| | |_ ______| | _ _ __ _ ___ ________| | ___ ___ | |___ ${NONE}"
echo -e "${RED}${BOLD}| | | / _ \ _/ _\` | | | | | __|______| | | | '_ \| | | \ \/ /______| |/ _ \ / _ \| / __| ${NONE}"
echo -e "${RED}${BOLD}| |/ / __/ || (_| | |_| | | |_ | |___| | | | | |_| |> < | | (_) | (_) | \__ \ ${NONE}"
echo -e "${RED}${BOLD}|___/ \___|_| \__,_|\__,_|_|\__| \_____/_|_| |_|\__,_/_/\_\ \_/\___/ \___/|_|___/ ${NONE}"
sleep 2
echo "Run install tools"
sleep 1
echo "Updating repositories.."
comprobate_gpl(){
local return_=1
which $1 >/dev/null 2>&1 || { local return_=0; }
echo "$return_"
}
yum=$(comprobate_gpl "yum")
apt=$(comprobate_gpl "apt")
if [ $apt -eq "1" ]; then
sudo apt update
elif [ $yum -eq "1" ]; then
sudo yum update
fi
tools_requirements=(git sed make wget curl)
tools_to_install=(vim tmux htop nmap screen i3lock-fancy glances zsh);
plugins_zsh=(git docker npm python sudo systemd web-search)
function echo_fail {
# echo first argument in red
printf "\e[31m✘ ${1} No Installed"
# reset colours back to normal
printf "\033[0m \n"
}
# display a message in green with a tick by it
# example
# echo echo_fail "Yes"
function echo_pass {
# echo first argument in green
printf "\e[32m✔ ${1} Installed"
# reset colours back to normal
printf "\033[0m \n"
}
check_tool_and_install(){
if type "$1" &>/dev/null; then
echo_pass $1
else
echo_fail $1
if [ $apt -eq "1" ]; then
sudo apt install $1 -y
elif [ $yum -eq "1" ]; then
sudo yum install $1 -y
fi
if [ "$1" = "zsh" ]; then
install_oh_my_zsh
elif [ "$1" = "i3lock-fancy" ]; then
install_lock
fi
fi
}
install_lock(){
if type git &>/dev/null; then
git clone https://github.com/meskarune/i3lock-fancy.git
cd i3lock-fancy/
sudo make install
cd ..
rm -rf i3lock-fancy/
else
wget https://github.com/meskarune/i3lock-fancy/archive/master.zip
unzip master.zip
cd i3lock-fancy-master
sudo make install
cd ..
rm -rf i3lock-fancy/
rm -rf master.zip
fi
}
install_oh_my_zsh(){
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
#quit start zsh for add plugins
sed -i 's/ env zsh -l/ /g' "./install.sh"
sh ./install.sh
#add default plugins to zsh
add_plugins_oh_my_zsh
rm ./install.sh
#start zsh
env zsh -l
}
add_plugins_oh_my_zsh(){
echo "Config plugins of oh my zsh"
echo "Plugins installed:"
for name in ${plugins_zsh[*]}
do
echo_pass $name
name_plugins+=" \n\t"$name
done
ruta=~/".zshrc"
sed -i "s/ git/ $name_plugins/g" "$ruta"
}
install_requirements(){
echo "Install Requirements"
for tool in ${tools_requirements[*]}
do
check_tool_and_install $tool
done
}
install_requirements
echo "Total tools: ${#tools_to_install[@]}";
for tool in ${tools_to_install[*]}
do
check_tool_and_install $tool
done