-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathsetup-fedora.sh
executable file
·182 lines (161 loc) · 4.93 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
clear
# -----------------------------------------------------
# Repository
# -----------------------------------------------------
repo="mylinuxforwork/dotfiles"
# -----------------------------------------------------
# Download Folder
# -----------------------------------------------------
download_folder="$HOME/.ml4w"
# Create download_folder if not exists
if [ ! -d $download_folder ]; then
mkdir -p $download_folder
fi
# 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 Download folder if not exists
if [ ! -d $download_folder ]; then
mkdir -p $download_folder
echo ":: $download_folder folder created"
fi
# Remove existing download folder and zip files
if [ -f $download_folder/dotfiles-main.zip ]; then
rm $download_folder/dotfiles-main.zip
fi
if [ -f $download_folder/dotfiles-dev.zip ]; then
rm $download_folder/dotfiles-dev.zip
fi
if [ -f $download_folder/dotfiles.zip ]; then
rm $download_folder/dotfiles.zip
fi
if [ -d $download_folder/dotfiles ]; then
rm -rf $download_folder/dotfiles
fi
if [ -d $download_folder/dotfiles_temp ]; then
rm -rf $download_folder/dotfiles_temp
fi
if [ -d $download_folder/dotfiles-main ]; then
rm -rf $download_folder/dotfiles-main
fi
if [ -d $download_folder/dotfiles-dev ]; then
rm -rf $download_folder/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 $download_folder/dotfiles
elif [ "$version" == "rolling-release" ]; then
echo ":: Installing Rolling Release"
echo
git clone --depth 1 https://github.com/mylinuxforwork/dotfiles.git $download_folder/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 $download_folder/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