forked from mylinuxforwork/hyprland-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·209 lines (184 loc) · 5.18 KB
/
setup.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# -----------------------------------------------------
# Functions for Setup
# -----------------------------------------------------
distro=""
installer=""
# Detect Linux Distribution
_detectDistro() {
if [ -f /etc/fedora-release ] ;then
distro="fedora"
installer="fedora"
echo ":: Installer for Fedora"
fi
if [ -f /etc/nobara-release ] ;then
distro="nobara"
installer="fedora"
echo ":: Installer for Nobara"
fi
if [ -f /etc/arch-release ] ;then
distro="arch"
installer="arch"
echo ":: Installer for Arch"
fi
}
# Check if package is installed
_isInstalledPacman() {
package="$1";
check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
# Install required packages
_installPackagesPacman() {
toInstall=();
for pkg; do
if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then
echo "${pkg} is already installed.";
continue;
fi;
toInstall+=("${pkg}");
done;
if [[ "${toInstall[@]}" == "" ]] ; then
# echo "All pacman packages are already installed.";
return;
fi;
printf "Package not installed:\n%s\n" "${toInstall[@]}";
sudo pacman --noconfirm -S "${toInstall[@]}";
}
# Check if package is installed
_isInstalledFedora() {
package="$1";
check=$(yum list installed | grep $package)
if [ -z "$check" ]; then
echo 1; #'1' means 'false' in Bash
return; #false
else
echo 0; #'0' means 'true' in Bash
return; #true
fi
}
# Install required packages
_installPackagesFedora() {
toInstall=();
for pkg; do
if [[ $(_isInstalledFedora "${pkg}") == 0 ]]; then
echo "${pkg} is already installed.";
continue;
fi;
toInstall+=("${pkg}");
done;
if [[ "${toInstall[@]}" == "" ]] ; then
# echo "All pacman packages are already installed.";
return;
fi;
printf "Package not installed:\n%s\n" "${toInstall[@]}";
sudo dnf install --assumeyes "${toInstall[@]}"
}
# -----------------------------------------------------
# Packages
# -----------------------------------------------------
# Required packages for the installer on Arch
installer_packages_arch=(
"figlet"
"git"
)
# Required packages for the installer on Fedora
installer_packages_fedora=(
"figlet"
"git"
)
clear
# Some colors
GREEN='\033[0;32m'
NONE='\033[0m'
# Header
echo -e "${GREEN}"
cat <<"EOF"
____ _
/ ___| ___| |_ _ _ _ __
\___ \ / _ \ __| | | | '_ \
___) | __/ |_| |_| | |_) |
|____/ \___|\__|\__,_| .__/
|_|
EOF
echo "for ML4W Hyprland Starter"
echo
echo -e "${NONE}"
echo "This script will download the ML4W Hyprland Starter and start the installation."
echo
while true; do
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn
case $yn in
[Yy]* )
echo "Installation started."
echo
break;;
[Nn]* )
echo "Installation canceled."
exit;
break;;
* ) echo "Please answer yes or no.";;
esac
done
# -----------------------------------------------------
# Detect Distribution
# -----------------------------------------------------
_detectDistro
if [ -z $distro ] ;then
echo "ERROR: Your Linux distribution could not be detected or is not supported."
echo
echo "Please select one of the following installation profiles or cancel the installation."
echo
version=$(gum choose "arch" "fedora" "cancel")
if [ "$version" == "arch" ] ;then
echo ":: Installer for Arch"
distro="arch"
installer="arch"
elif [ "$version" == "rolling-release" ] ;then
echo ":: Installer for Fedora"
distro="fedora"
installer="fedora"
elif [ "$version" == "cancel" ] ;then
echo ":: Setup canceled"
exit 130
else
echo ":: Setup canceled"
exit 130
fi
fi
# -----------------------------------------------------
# Installation for Fedora
# -----------------------------------------------------
if [ "$installer" == "fedora" ] ;then
_installPackagesFedora "${installer_packages_fedora[@]}";
fi
# -----------------------------------------------------
# Installation for Arch
# -----------------------------------------------------
if [ "$installer" == "arch" ] ;then
_installPackagesPacman "${installer_packages_arch[@]}";
fi
# Create Downloads folder if not exists
if [ ! -d ~/Downloads ] ;then
mkdir ~/Downloads
echo ":: Downloads folder created"
fi
# Change into Downloads directory
cd ~/Downloads
# Remove existing folder
if [ -d ~/Downloads/hyprland-starter ] ;then
rm -rf ~/Downloads/hyprland-starter
echo ":: Existing installation folder removed"
fi
# Clone the packages
git clone --depth 1 https://github.com/mylinuxforwork/hyprland-starter.git
echo ":: Installation files cloned into Downloads folder"
# Change into the folder
cd hyprland-starter
# Start the script
./install.sh