-
Notifications
You must be signed in to change notification settings - Fork 95
/
setup-fedora.sh
executable file
·167 lines (148 loc) · 4.52 KB
/
setup-fedora.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
#!/bin/bash
clear
repo="mylinuxforwork/dotfiles"
# Get latest tag from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$repo/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Get latest zip from GitHub
get_latest_zip() {
curl --silent "https://api.github.com/repos/$repo/releases/latest" | # Get latest release from GitHub api
grep '"zipball_url":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Check if package is installed
_isInstalled() {
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
_installPackages() {
toInstall=();
for pkg; do
if [[ $(_isInstalled "${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[@]}"
}
# Required packages for the installer
packages=(
"wget"
"unzip"
"rsync"
"git"
"figlet"
)
latest_version=$(get_latest_release)
# Some colors
GREEN='\033[0;32m'
NONE='\033[0m'
# Header
echo -e "${GREEN}"
cat <<"EOF"
____ __ ____
/ _/__ ___ / /____ _/ / /__ ____
_/ // _ \(_-</ __/ _ `/ / / -_) __/
/___/_//_/___/\__/\_,_/_/_/\__/_/
EOF
echo "ML4W Dotfiles for Hyprland"
echo -e "${NONE}"
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
# Create Downloads folder if not exists
if [ ! -d ~/Downloads ]; then
mkdir ~/Downloads
echo ":: Downloads folder created"
fi
# Remove existing download folder and zip files
if [ -f $HOME/Downloads/dotfiles-main.zip ]; then
rm $HOME/Downloads/dotfiles-main.zip
fi
if [ -f $HOME/Downloads/dotfiles-dev.zip ]; then
rm $HOME/Downloads/dotfiles-dev.zip
fi
if [ -f $HOME/Downloads/dotfiles.zip ]; then
rm $HOME/Downloads/dotfiles.zip
fi
if [ -d $HOME/Downloads/dotfiles ]; then
rm -rf $HOME/Downloads/dotfiles
fi
if [ -d $HOME/Downloads/dotfiles_temp ]; then
rm -rf $HOME/Downloads/dotfiles_temp
fi
if [ -d $HOME/Downloads/dotfiles-main ]; then
rm -rf $HOME/Downloads/dotfiles-main
fi
if [ -d $HOME/Downloads/dotfiles-dev ]; then
rm -rf $HOME/Downloads/dotfiles-dev
fi
# Install required packages
echo ":: Checking that required packages are installed..."
_installPackages "${packages[@]}";
bash <(curl -s https://raw.githubusercontent.com/mylinuxforwork/dotfiles/main/share/packages/fedora/special/gum.sh)
echo
# Select the dotfiles version
echo "Please choose between: "
echo "- ML4W Dotfiles for Hyprland $latest_version (latest stable release)"
echo "- ML4W Dotfiles for Hyprland Rolling Release (main branch including the latest commits)"
echo
version=$(gum choose "main-release" "rolling-release" "cancel")
if [ "$version" == "main-release" ]; then
echo ":: Installing Main Release"
echo
git clone --branch $latest_version --depth 1 https://github.com/mylinuxforwork/dotfiles.git ~/Downloads/dotfiles
elif [ "$version" == "rolling-release" ]; then
echo ":: Installing Rolling Release"
echo
git clone --depth 1 https://github.com/mylinuxforwork/dotfiles.git ~/Downloads/dotfiles
elif [ "$version" == "cancel" ]; then
echo ":: Setup canceled"
exit 130
else
echo ":: Setup canceled"
exit 130
fi
echo ":: Download complete."
echo
# Cd into dotfiles folder
cd $HOME/Downloads/dotfiles/bin/
# Start Spinner
gum spin --spinner dot --title "Starting the installation now..." -- sleep 3
# Start installation
./ml4w-hyprland-setup -m install
echo
# Start Spinner
gum spin --spinner dot --title "Starting the setup now..." -- sleep 3
# Start setup
./ml4w-hyprland-setup -p fedora