-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathinstall
117 lines (102 loc) · 2.77 KB
/
install
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
#!/bin/bash
package_name="clifty"
link_clifty="https://github.com/Alygnt/Clifty"
link_clifty_raw="https://raw.githubusercontent.com/Alygnt/Clifty/main"
clear
cd $HOME
version=$(curl -s "${link_clifty_raw}/assets/update/version.txt")
version="1.5"
#Check whether package is installed
package_installed() {
local package_name=$1
if dpkg -l | awk '{print $2}' | grep -wq "$package_name"; then
return 0 # Package is installed
else
return 1 # Package is not installed
fi
}
latest_version() {
current_ver=$(clifty -v)
if [ "$version" == "$current_ver" ]; then
clifty -cb
echo -ne "\nYou already have Clifty latest version"
echo -ne "\nType 'clifty' to run it"
else
install_now
fi
}
# Function to install dependencies
dependencies() {
if [[ $(command -v curl) ]]; then
echo -ne ""
else
pkgs=(curl wget)
for pkg in "${pkgs[@]}"; do
type -p "$pkg" &>/dev/null || {
if [[ $(command -v pkg) ]]; then
pkg install "$pkg" -y
elif [[ $(command -v apt) ]]; then
apt install "$pkg" -y
elif [[ $(command -v apt-get) ]]; then
apt-get install "$pkg" -y
elif [[ $(command -v pacman) ]]; then
sudo pacman -S "$pkg" --noconfirm
elif [[ $(command -v dnf) ]]; then
sudo dnf -y install "$pkg"
else
echo -e "\n Unsupported package manager, Install packages manually."
{ reset_color; exit 1; }
fi
}
done
fi
}
# Function to set variables
variables() {
version=$(curl -s https://raw.githubusercontent.com/Alygnt/Clifty/main/assets/update/version.txt)
link_clifty="https://github.com/Alygnt/Clifty"
}
# Function to install Clifty
install_deb() {
wget --no-check-certificate ${link_clifty}/releases/download/v_${version}/clifty_${version}.deb > /dev/null 2>&1
if [[ $(command -v termux-chroot) ]]; then
termux-chroot dpkg -i clifty_${version}.deb
else
if [ "$SUDO_USER" ]; then
sudo dpkg -i "clifty_${version}.deb"
else
dpkg -i "clifty_${version}.deb"
fi
fi
rm -rf clifty_${version}.deb
}
# Function to clean up
clean() {
if [ -e install ]; then
rm -rf install
fi
}
# Function to run Clifty
run() {
if [ "$SUDO_USER" ]; then
sudo clifty
else
clifty
fi
}
finish(){
clear
clifty -b
echo -ne "\nClifty tool is now ready type 'clifty' to run it"
}
install_now(){
dependencies
variables
install_deb
}
if package_installed "$package_name"; then
latest_version
else
install_now
finish
fi