-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal_functions.sh
47 lines (41 loc) · 1.29 KB
/
Global_functions.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
#!/bin/bash
# 💫 https://github.com/ShinjiMC 💫 #
if [ ! -d Install-Logs ]; then
mkdir Install-Logs
fi
set -e
OK="$(tput setaf 2)[OK]$(tput sgr0)"
ERROR="$(tput setaf 1)[ERROR]$(tput sgr0)"
NOTE="$(tput setaf 3)[NOTE]$(tput sgr0)"
WARN="$(tput setaf 166)[WARN]$(tput sgr0)"
CAT="$(tput setaf 6)[ACTION]$(tput sgr0)"
ORANGE=$(tput setaf 166)
YELLOW=$(tput setaf 3)
RESET=$(tput sgr0)
set -e
install_package() {
if sudo dnf list installed "$1" &>> /dev/null ; then
echo -e "${OK} $1 is already installed. Skipping..."
else
echo -e "${NOTE} Installing $1 ..."
sudo dnf install -y "$1" 2>&1 | tee -a "$LOG"
if sudo dnf list installed "$1" &>> /dev/null ; then
echo -e "\e[1A\e[K${OK} $1 was installed."
else
echo -e "\e[1A\e[K${ERROR} $1 failed to install :( , please check the install.log. You may need to install manually! Sorry I have tried :("
exit 1
fi
fi
}
uninstall_package() {
if sudo dnf list installed "$1" &>> /dev/null ; then
echo -e "${NOTE} Uninstalling $1 ..."
sudo dnf remove -y "$1" 2>&1 | tee -a "$LOG"
if ! sudo dnf list installed "$1" &>> /dev/null ; then
echo -e "\e[1A\e[K${OK} $1 was uninstalled."
else
echo -e "\e[1A\e[K${ERROR} $1 failed to uninstall. Please check the uninstall.log."
exit 1
fi
fi
}