-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
309 lines (271 loc) · 11.5 KB
/
install.sh
File metadata and controls
309 lines (271 loc) · 11.5 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/bin/bash
#################################################
## Installation Instructions ##
#################################################
# Step 1: Download the repository
# --------------------------------
# Open a terminal and run:
# sudo pacman -S git
# git clone https://github.com/dillacorn/awtarchy
# Step 2: Run the installer
# -------------------------
# Navigate to the awtarchy directory:
# cd awtarchy
# Make the installer executable and run it:
# chmod +x install.sh
# sudo ./install.sh
# Follow the on-screen instructions.
#################################################
## End of Instructions ##
#################################################
# Color Variables
COLOR_RED="\033[1;31m"
COLOR_GREEN="\033[1;32m"
COLOR_YELLOW="\033[1;33m"
COLOR_BLUE="\033[1;34m"
COLOR_MAGENTA="\033[1;35m"
COLOR_CYAN="\033[1;36m"
COLOR_RESET="\033[0m"
# Global Variables
HOME_DIR="/home/$SUDO_USER"
REPO_DIR="$HOME_DIR/awtarchy"
REQUIRED_SPACE_MB=1024
INSTALL_SCRIPTS=(
"install_arch_repo_apps.sh"
"install_aur_repo_apps.sh"
"install_flatpak_apps.sh"
"install_alacritty_themes.sh"
"install_GPU_dependencies.sh"
"install_micro_themes.sh"
"enable_keyring_pam.sh"
"install_ly.sh"
)
# Ensure the script is run with sudo
if [ -z "$SUDO_USER" ]; then
echo -e "${COLOR_RED}This script must be run with sudo!${COLOR_RESET}"
exit 1
fi
retry_command() {
local retries=3 count=0
local exit_code
until "$@"; do
exit_code=$?
((count++))
echo -e "${COLOR_RED}Attempt $count/$retries failed for command:${COLOR_RESET}"
printf "'%s' " "$@"; echo
if [ "$count" -lt "$retries" ]; then
echo -e "${COLOR_RED}Retrying...${COLOR_RESET}"
sleep 2
else
echo -e "${COLOR_RED}Command failed after $retries attempts. Exiting.${COLOR_RESET}"
return "$exit_code"
fi
done
}
create_directory() {
local dir="$1"
if [ ! -d "$dir" ]; then
echo -e "${COLOR_YELLOW}Creating missing directory: ${COLOR_CYAN}$dir${COLOR_RESET}"
retry_command mkdir -p "$dir" || {
echo -e "${COLOR_RED}Failed to create directory ${COLOR_CYAN}$dir${COLOR_RESET}. Exiting.${COLOR_RESET}"
exit 1
}
fi
retry_command chown "$SUDO_USER:$SUDO_USER" "$dir"
retry_command chmod 755 "$dir"
}
# First confirmation
echo -e "${COLOR_RED}WARNING: This script will overwrite the following directories:${COLOR_RESET}"
echo -e "${COLOR_YELLOW}
- ~/.config/hypr
- ~/.config/waybar
- ~/.config/alacritty
- ~/.config/wofi
- ~/.config/fuzzel
- ~/.config/mako
- ~/.config/gtk-3.0
- ~/.config/Kvantum
- ~/.config/pcmanfm-qt
- ~/.config/yazi
- ~/.config/SpeedCrunch
- ~/.config/fastfetch
- ~/.config/wlogout
- ~/.config/qt5ct
- ~/.config/qt6ct
- ~/.config/xdg-desktop-portal
- ~/.config/lsfg-vk
- ~/.config/wiremix
- ~/.config/cava
- ~/.Xresources
- ~/.local/share/nwg-look/gsettings${COLOR_RESET}"
echo -e "${COLOR_RED}Are you sure you want to continue? This action CANNOT be undone.${COLOR_RESET}"
echo -e "${COLOR_GREEN}Press 'y' to continue or 'n' to cancel. Default is 'yes' if Enter is pressed:${COLOR_RESET}"
read -r -n 1 first_confirmation
echo
if [[ "$first_confirmation" != "y" && "$first_confirmation" != "Y" && "$first_confirmation" != "" ]]; then
echo -e "${COLOR_RED}Installation canceled by user.${COLOR_RESET}"
exit 1
fi
# Second confirmation
echo -e "${COLOR_MAGENTA}This is your last chance! Are you absolutely sure? (y/n)${COLOR_RESET}"
read -r -n 1 second_confirmation
echo
if [[ "$second_confirmation" != "y" && "$second_confirmation" != "Y" && "$second_confirmation" != "" ]]; then
echo -e "${COLOR_RED}Installation canceled by user.${COLOR_RESET}"
exit 1
fi
# Adding pause before continuing
echo -e "${COLOR_GREEN}Proceeding with the installation...${COLOR_RESET}"
read -r -p "Press Enter to continue..."
# Check disk space
AVAILABLE_SPACE_MB=$(df --output=avail / | tail -1)
AVAILABLE_SPACE_MB=$((AVAILABLE_SPACE_MB / 1024))
if [ "$AVAILABLE_SPACE_MB" -lt "$REQUIRED_SPACE_MB" ]; then
echo -e "${COLOR_RED}Not enough disk space (1GB required). Exiting.${COLOR_RESET}"
exit 1
fi
# Update system and install basic packages
echo -e "${COLOR_BLUE}Updating package list and installing git...${COLOR_RESET}"
if ! retry_command pacman -Syu --noconfirm; then
echo -e "${COLOR_RED}Failed to update package list. Refreshing mirrors...${COLOR_RESET}"
retry_command reflector --verbose --latest 5 --sort rate --save /etc/pacman.d/mirrorlist
retry_command pacman -Syu --noconfirm || exit 1
fi
retry_command pacman -S --needed --noconfirm git ipcalc dos2unix reflector xcursor-comix || exit 1
# Clone repository if not exists
if [ ! -d "$REPO_DIR" ]; then
echo -e "${COLOR_BLUE}Cloning awtarchy repository to ${COLOR_CYAN}${REPO_DIR}${COLOR_RESET}...${COLOR_RESET}"
retry_command git clone https://github.com/dillacorn/awtarchy "$REPO_DIR" || exit 1
fi
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$REPO_DIR"
# Convert line endings
echo -e "${COLOR_BLUE}Converting files to Unix line endings...${COLOR_RESET}"
find "$REPO_DIR" -type f -exec dos2unix {} + 2>/dev/null
# Run installation scripts in order
cd "$REPO_DIR/scripts" || exit 1
for script in "${INSTALL_SCRIPTS[@]}"; do
echo -e "${COLOR_BLUE}Running ${COLOR_CYAN}$script${COLOR_RESET}...${COLOR_RESET}"
chmod +x "$script"
# Special handling for GPU script in VMs
if [[ "$script" == "install_GPU_dependencies.sh" ]] && systemd-detect-virt --quiet; then
echo -e "${COLOR_YELLOW}Skipping GPU script in virtual machine${COLOR_RESET}"
continue
fi
retry_command "./$script" || { echo -e "${COLOR_RED}$script failed!${COLOR_RESET}"; exit 1; }
read -r -p "Press Enter to continue..."
done
# Handle .bashrc and .bash_profile with user confirmation
for config_file in bashrc bash_profile; do
if [ -f "$HOME_DIR/.$config_file" ]; then
echo -e "${COLOR_YELLOW}$HOME_DIR/.$config_file exists. Overwrite? (y/N)${COLOR_RESET}"
read -r -n 1 response
echo
if [[ "$response" =~ ^[Yy]$ ]]; then
retry_command cp "$REPO_DIR/$config_file" "$HOME_DIR/.$config_file"
# Special handling for Btrfs
if findmnt -n -o FSTYPE / | grep -qi btrfs; then
sed -i '/alias flatpak=.flatpak --user./ s/^/#/' "$HOME_DIR/.$config_file"
echo "Btrfs detected on root. Commented out flatpak --user alias in .$config_file"
fi
retry_command chown "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.$config_file"
retry_command chmod 644 "$HOME_DIR/.$config_file"
fi
else
retry_command cp "$REPO_DIR/$config_file" "$HOME_DIR/.$config_file"
retry_command chown "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.$config_file"
retry_command chmod 644 "$HOME_DIR/.$config_file"
fi
done
# Copy all configuration files
echo -e "${COLOR_BLUE}Copying configuration files...${COLOR_RESET}"
config_dirs=("hypr" "waybar" "alacritty" "wlogout" "mako" "wofi" "fuzzel"
"gtk-3.0" "Kvantum" "SpeedCrunch" "fastfetch" "pcmanfm-qt" "yazi" "xdg-desktop-portal" "qt5ct" "qt6ct" "lsfg-vk" "wiremix" "cava")
for dir in "${config_dirs[@]}"; do
retry_command cp -r "$REPO_DIR/config/$dir" "$HOME_DIR/.config/" || exit 1
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.config/$dir"
done
# Create directory if it doesn't exist
create_directory "$HOME_DIR/.local/share/nwg-look"
create_directory "$HOME_DIR/.local/share/SpeedCrunch"
create_directory "$HOME_DIR/.local/share/SpeedCrunch/color-schemes"
# Special files
retry_command cp "$REPO_DIR/Xresources" "$HOME_DIR/.Xresources"
retry_command cp "$REPO_DIR/config/mimeapps.list" "$HOME_DIR/.config/"
retry_command cp "$REPO_DIR/config/gamemode.ini" "$HOME_DIR/.config/"
retry_command cp "$REPO_DIR/local/share/nwg-look/gsettings" "$HOME_DIR/.local/share/nwg-look/"
retry_command chown "$SUDO_USER:$SUDO_USER" \
"$HOME_DIR/.Xresources" \
"$HOME_DIR/.config/mimeapps.list" \
"$HOME_DIR/.config/gamemode.ini" \
"$HOME_DIR/.local/share/nwg-look/gsettings"
retry_command chmod 644 \
"$HOME_DIR/.Xresources" \
"$HOME_DIR/.config/mimeapps.list" \
"$HOME_DIR/.config/gamemode.ini" \
"$HOME_DIR/.local/share/nwg-look/gsettings"
# SpeedCrunch color schemes
retry_command cp "$REPO_DIR/local/share/SpeedCrunch/color-schemes/"*.json "$HOME_DIR/.local/share/SpeedCrunch/color-schemes/"
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.local/share/SpeedCrunch"
retry_command chmod 644 "$HOME_DIR/.local/share/SpeedCrunch/color-schemes/"*.json
# Desktop entries
create_directory "$HOME_DIR/.local/share/applications"
retry_command cp -r "$REPO_DIR/local/share/applications/." "$HOME_DIR/.local/share/applications"
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.local/share/applications"
find "$HOME_DIR/.local/share/applications" -type d -exec chmod 755 {} +
find "$HOME_DIR/.local/share/applications" -type f -exec chmod 644 {} +
# Cursor theme
create_directory "$HOME_DIR/.local/share/icons/ComixCursors-White"
retry_command cp -r /usr/share/icons/ComixCursors-White/* "$HOME_DIR/.local/share/icons/ComixCursors-White/"
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.local/share/icons/ComixCursors-White"
find "$HOME_DIR/.local/share/icons/ComixCursors-White" -type d -exec chmod 755 {} +
find "$HOME_DIR/.local/share/icons/ComixCursors-White" -type f -exec chmod 644 {} +
# System-wide cursor
cat > /usr/share/icons/default/index.theme <<EOF
[Icon Theme]
Inherits=ComixCursors-White
EOF
chmod 644 /usr/share/icons/default/index.theme
# Flatpak cursor (apply to target user, not root)
if command -v flatpak &>/dev/null; then
sudo -u "$SUDO_USER" flatpak override --user --env=GTK_CURSOR_THEME=ComixCursors-White || true
fi
# Wallpaper setup
create_directory "$HOME_DIR/Pictures/wallpapers"
create_directory "$HOME_DIR/Pictures/Screenshots"
retry_command cp \
"$REPO_DIR/awtarchy_geology.png" \
"$REPO_DIR/awtarchy_space.png" \
"$HOME_DIR/Pictures/wallpapers/"
retry_command chown "$SUDO_USER:$SUDO_USER" \
"$HOME_DIR/Pictures/wallpapers/awtarchy_geology.png" \
"$HOME_DIR/Pictures/wallpapers/awtarchy_space.png"
retry_command chmod 644 \
"$HOME_DIR/Pictures/wallpapers/awtarchy_geology.png" \
"$HOME_DIR/Pictures/wallpapers/awtarchy_space.png"
# Final permissions
find "$HOME_DIR/.config" -type d -exec chmod 755 {} +
find "$HOME_DIR/.config" -type f -exec chmod 644 {} +
find "$HOME_DIR/.config/hypr/scripts" -type f -exec chmod +x {} +
find "$HOME_DIR/.config/hypr/themes" -type f -exec chmod +x {} +
find "$HOME_DIR/.config/waybar/scripts" -type f -exec chmod +x {} +
# Ownership & permission repair (fix user unable to write in $HOME)
echo -e "${COLOR_BLUE}Repairing ownership under ${COLOR_CYAN}$HOME_DIR${COLOR_BLUE}...${COLOR_RESET}"
retry_command chown "$SUDO_USER:$SUDO_USER" "$HOME_DIR"
find "$HOME_DIR" -mindepth 1 ! -user "$SUDO_USER" -exec chown -h "$SUDO_USER:$SUDO_USER" {} + 2>/dev/null
if [ -d "$HOME_DIR/.ssh" ]; then
retry_command chown -R "$SUDO_USER:$SUDO_USER" "$HOME_DIR/.ssh"
chmod 700 "$HOME_DIR/.ssh"
find "$HOME_DIR/.ssh" -type f -exec chmod 600 {} +
fi
echo -e "${COLOR_GREEN}Ownership repair complete.${COLOR_RESET}"
# Reboot prompt
echo -e "${COLOR_GREEN}Setup complete! Reboot recommended.${COLOR_RESET}"
read -r -n 1 -p "Reboot now? [Y/n] " reboot_choice
echo
if [[ "$reboot_choice" =~ ^[Nn]$ ]]; then
echo -e "${COLOR_GREEN}Reboot skipped. You can reboot manually later.${COLOR_RESET}"
else
echo -e "${COLOR_BLUE}Rebooting...${COLOR_RESET}"
sleep 1
reboot
fi