forked from Ptechgithub/configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.sh
114 lines (100 loc) · 3.19 KB
/
bash.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
#!/bin/bash
#colors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
blue='\033[0;34m'
purple='\033[0;35m'
cyan='\033[0;36m'
white='\033[0;37m'
rest='\033[0m'
#-------------------------------------------------------#
# root check
root() {
if [[ $EUID -ne 0 ]]; then
echo -e "${red}Please run as root. Use [sudo -i]${rest}"
exit 1
fi
}
#-------------------------------------------------------#
#progress
display_progress() {
local duration=$1
local sleep_interval=0.1
local progress=0
local bar_length=40
local colors=("[41m" "[42m" "[43m" "[44m" "[45m" "[46m" "[47m")
while [ $progress -lt $duration ]; do
echo -ne "\r${colors[$((progress % 7))]}"
for ((i = 0; i < bar_length; i++)); do
if [ $i -lt $((progress * bar_length / duration)) ]; then
echo -ne "█"
else
echo -ne "░"
fi
done
echo -ne "[0m ${progress}%"
progress=$((progress + 1))
sleep $sleep_interval
done
echo -ne "\r${colors[0]}"
for ((i = 0; i < bar_length; i++)); do
echo -ne " "
done
echo -ne "[0m 100%"
echo
}
#apt upgrade -y > /dev/null 2>&1 &
#pid=$!
#display_progress 10
#wait "$pid"
#-------------------------------------------------------#
#logo
logo_animated() {
colors=("\e[92m" "\e[91m" "\e[93m" "\e[94m" "\e[95m" "\e[96m" "\e[93m" "\e[96m")
NC="\e[0m"
for color in "${colors[@]}"; do
clear
echo -e "\n${color}
___ ___ ___ ___ ___ ___
/\ \ /\ \ |\__\ /\__\ /\ \ /\__\
/::\ \ /::\ \ |:| | /::| | /::\ \ /::| |
/:/\:\ \ /:/\:\ \ |:| | /:|:| | /:/\:\ \ /:|:| |
/::\~\:\ \ /::\~\:\ \ |:|__|__ /:/|:|__|__ /::\~\:\ \ /:/|:| |__
/:/\:\ \:\__/:/\:\ \:\__\/::::\__/:/ |::::\__/:/\:\ \:\__/:/ |:| /\__\
\/__\:\/:/ \:\~\:\ \/__/:/~~/~ \/__/~~/:/ \/__\:\/:/ \/__|:|/:/ /
\::/ / \:\ \:\__\/:/ / /:/ / \::/ / |:/:/ /
\/__/ \:\ \/__/\/__/ /:/ / /:/ / |::/ /
\:\__\ /:/ / /:/ / /:/ /
\/__/ \/__/ \/__/ \/__/
${R}\n"
sleep 0.2
done
}
#-------------------------------------------------------#
#dependencies
dependencies() {
if command -v apt-get &> /dev/null; then
package_manager="apt"
elif command -v yum &> /dev/null; then
package_manager="yum"
elif command -v dnf &> /dev/null; then
package_manager="dnf"
else
echo "Unsupported package manager. Exiting..."
exit 1
fi
programs=("wget" "curl" "nano")
for program in "${programs[@]}"; do
if ! command -v "$program" &> /dev/null; then
echo "$program is not installed. Installing..."
sudo "$package_manager" install -y "$program"
else
echo "$program installed."
fi
done
}
update() {
dependencies
"$package_manager" update -y
}