forked from softwaresocialist/TurboTux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
510 lines (448 loc) · 16.1 KB
/
setup.sh
File metadata and controls
510 lines (448 loc) · 16.1 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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
#!/usr/bin/env bash
# Check if the script is run as root
if [[ "$EUID" -ne 0 ]]; then
echo "Please run this script as root or using sudo."
exit 1
fi
# Determine target user (assumes script is run via sudo)
TARGET_USER=$(logname)
HOME_DIR="/home/$TARGET_USER"
SETUP_DIR="$HOME_DIR/Arch-setup"
# Create setup directory
mkdir -p "$SETUP_DIR"
chown "$TARGET_USER:$TARGET_USER" "$SETUP_DIR"
# Display logo
echo -e " $(cat << 'EOF'
-`
.o+`
`ooo/
`+oooo:
`+oooooo:
-+oooooo+:
`/:-:++oooo+:
`/++++/+++++++:
`/++++++++++++++:
`/+++ooooooooooooo/`
./ooosssso++osssssso+`
.oossssso-````/ossssss+`
-osssssso. :ssssssso.
:osssssss/ osssso+++.
/ossssssss/ +ssssooo/-
`/ossssso+/:- -:/+osssso+-
`+sso+:-` `.-/+oso:
`++:. `-/+/
EOF
)"
# Ask to install necessary base dependencies and add multilib repo
while true; do
echo "Would you like to install required dependencies (yay reflector,wget, gnupg, curl, flatpak, etc.) and add the multilib repository? (y/n)"
read -r deps_answer
if [[ "$deps_answer" == "y" || "$deps_answer" == "Y" ]]; then
echo "Updating and upgrading system packages..."
pacman -Syu --noconfirm
# Enable multilib repo if not already enabled
if ! grep -Pzo '\[multilib\]\n(?:#.*\n)*#?Include = /etc/pacman.d/mirrorlist' /etc/pacman.conf | grep -qv '^Include'; then
echo "Enabling multilib repository..."
sudo sed -i '/^\[multilib\]$/,/^$/{s/^#\(Include = \/etc\/pacman\.d\/mirrorlist\)/\1/}' /etc/pacman.conf
sudo pacman -Sy
else
echo "Multilib repository already enabled."
fi
echo "Checking and installing required dependencies..."
pacman -S --needed --noconfirm reflector wget gnupg curl git flatpak base-devel
cd /tmp
sudo -u "$TARGET_USER" git clone https://aur.archlinux.org/yay.git
cd yay
sudo -u "$TARGET_USER" makepkg -si --noconfirm
break
elif [[ "$deps_answer" == "n" || "$deps_answer" == "N" ]]; then
echo "Dependency installation is required for this script to work. Exiting."
exit 1
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Chaotic-AUR
while true; do
echo "Would you like to add the Chaotic-AUR Repository? (y/n)"
read -r chaotic_answer
if [[ "$chaotic_answer" == "y" || "$chaotic_answer" == "Y" ]]; then
echo "Downloading and installing chaotic-AUR..."
pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
pacman-key --lsign-key 3056513887B78AEB
pacman -U --noconfirm \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
echo -e '\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist' | sudo tee -a /etc/pacman.conf
pacman -Syyuu --noconfirm
break
elif [[ "$chaotic_answer" == "n" || "$chaotic_answer" == "N" ]]; then
echo "Chaotic-AUR installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Lutris installation
while true; do
echo "Would you like to install Lutris (EA/EPIC/UBISOFT support)? (y/n)"
read -r lutris_answer
if [[ "$lutris_answer" == "y" || "$lutris_answer" == "Y" ]]; then
echo "Downloading and installing Lutris..."
pacman -S --noconfirm --needed lutris
break
elif [[ "$lutris_answer" == "n" || "$lutris_answer" == "N" ]]; then
echo "Lutris installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Steam installation
while true; do
echo "Would you like to install steam? (y/n)"
read -r steam_answer
if [[ "$steam_answer" == "y" || "$steam_answer" == "Y" ]]; then
sudo pacman -S --noconfirm --needed steam
break
elif [[ "$steam_answer" == "n" || "$steam_answer" == "N" ]]; then
echo "Steam installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# lug-helperr installation
while true; do
echo "Would you like to install lug-helper (Star-citizen)? (y/n)"
read -r lug_answer
if [[ "$lug_answer" == "y" || "$lug_answer" == "Y" ]]; then
sudo -u "$TARGET_USER" yay -S --noconfirm --needed lug-helper
break
elif [[ "$lug_answer" == "n" || "$lug_answer" == "N" ]]; then
echo "lug-helper installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Heroic Games Launcher installation
while true; do
echo "Would you like to install Heroic Games Launcher (Epic/GOG/PRIME support)? (y/n)"
read -r heroic_answer
if [[ "$heroic_answer" == "y" || "$heroic_answer" == "Y" ]]; then
sudo -u "$TARGET_USER" yay -S --noconfirm --needed heroic-games-launcher-bin
break
elif [[ "$heroic_answer" == "n" || "$heroic_answer" == "N" ]]; then
echo "Heroic Games Launcher installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install prismlauncher
while true; do
echo "Install prismlauncher (Minecraft launcher for mods? (y/n)"
read -r prism_answer
if [[ "$prism_answer" == "y" || "$prism_answer" == "Y" ]]; then
pacman -S --noconfirm --needed prismlauncher
echo "Prismlauncher installed successfully."
break
elif [[ "$prism_answer" == "n" || "$prism_answer" == "N" ]]; then
echo "Prismlauncher Driver installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# General Gaming Optimizations
while true; do
echo "Apply General Gaming optimizations and install necessary software(arch-gaming-meta/Cachyos-ananicy rules)? (y/n)"
read -r General_answer
if [[ "$General_answer" == "y" || "$General_answer" == "Y" ]]; then
# Install software
sudo -u "$TARGET_USER" yay -S --noconfirm --needed arch-gaming-meta cachyos-ananicy-rules
systemctl enable --now ananicy-cpp.service
#systctl.d tweaks
sysctl -w vm.swappiness=100
echo 'vm.swappiness=100' | sudo tee -a /etc/sysctl.conf
sysctl -w vm.vfs_cache_pressure=50
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf
sysctl -w vm.dirty_bytes=268435456
echo 'vm.dirty_bytes=268435456' | sudo tee -a /etc/sysctl.conf
sysctl -w vm.dirty_background_bytes=67108864
echo 'vm.dirty_background_bytes=67108864' | sudo tee -a /etc/sysctl.conf
sysctl -w vm.dirty_writeback_centisecs=1500
echo 'vm.dirty_writeback_centisecs=1500' | sudo tee -a /etc/sysctl.conf
sysctl -w kernel.nmi_watchdog=0
echo 'kernel.nmi_watchdog=0' | sudo tee -a /etc/sysctl.conf
sysctl -w kernel.unprivileged_userns_clone=1
echo 'kernel.unprivileged_userns_clone=1' | sudo tee -a /etc/sysctl.conf
sysctl -w kernel.kptr_restrict=2
echo 'kernel.kptr_restrict=2' | sudo tee -a /etc/sysctl.conf
sysctl -w net.core.netdev_max_backlog=4096
echo 'net.core.netdev_max_backlog=4096' | sudo tee -a /etc/sysctl.conf
sysctl -w fs.file-max=2097152
echo 'fs.file-max=2097152' | sudo tee -a /etc/sysctl.conf
sysctl -w fs.xfs.xfssyncd_centisecs=10000
echo 'fs.xfs.xfssyncd_centisecs=10000' | tee -a /etc/sysctl.conff
# ZRAM Setup
echo "Setting up zram swap (half of total RAM)..."
# Install zram-generator if not present
if ! command -v zramctl >/dev/null || ! [[ -f /usr/lib/systemd/system-generators/zram-generator ]]; then
echo "Installing zram-generator..."
pacman -S --noconfirm zram-generator
fi
# Get total memory in MiB
TOTAL_MEM=$(awk '/MemTotal/ {print int($2 / 1024)}' /proc/meminfo)
ZRAM_SIZE=$((TOTAL_MEM / 2))
# Create zram config
mkdir -p /etc/systemd/zram-generator.conf.d
cat > /etc/systemd/zram-generator.conf.d/00-zram.conf <<EOF
[zram0]
zram-size = ${ZRAM_SIZE}
compression-algorithm = zstd
EOF
# Trigger zram generator
systemctl daemon-reexec
# Start zram swap
if systemctl start systemd-zram-setup@zram0.service; then
echo "ZRAM swap started successfully with size ${ZRAM_SIZE}MiB."
else
echo "Failed to start ZRAM swap. Check configuration and journal logs."
fi
break
elif [[ "$General_answer" == "n" || "$General_answer" == "N" ]]; then
echo "General Gaming Optimizations skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
while true; do
echo "Install Nvidia drivers? (y/n)"
read -r driver_answer
if [[ "$driver_answer" == "y" || "$driver_answer" == "Y" ]]; then
# Detect NVIDIA GPU model
gpu_model=$(lspci | grep -i 'VGA\|3D' | grep -i nvidia)
if [[ -z "$gpu_model" ]]; then
echo "No NVIDIA GPU found. No driver will be installed."
exit 0
fi
# Extract PCI device ID (e.g. 10de:2500)
pci_entry=$(lspci -n | grep -i 'VGA\|3D' | grep -i nvidia | head -n1 | awk '{print $3}')
device_id_hex=${pci_entry#*:} # part after colon
# Convert hex to decimal for comparison
device_id_dec=$((16#$device_id_hex))
# Select driver based on PCI device ID
if (( device_id_dec >= 0x2500 )); then
driver="nvidia-open"
elif (( device_id_dec >= 0x1000 )); then
driver="nvidia"
elif (( device_id_dec >= 0x0C00 )); then
driver="nvidia-470xx"
elif (( device_id_dec >= 0x0600 )); then
driver="nvidia-390xx"
elif (( device_id_dec >= 0x0300 )); then
driver="nvidia-340xx"
else
driver="nouveau"
fi
echo "Detected GPU: $gpu_model"
echo "Selected driver: $driver"
check_driver_packages() {
local driver=$1
case "$driver" in
nvidia)
pkgs=(nvidia nvidia-utils nvidia-settings)
;;
nvidia-open)
pkgs=(nvidia-open nvidia-utils nvidia-settings)
;;
nvidia-470xx)
pkgs=(nvidia-470xx nvidia-470xx-utils)
;;
nvidia-390xx)
pkgs=(nvidia-390xx nvidia-390xx-utils)
;;
nvidia-340xx)
pkgs=(nvidia-340xx nvidia-340xx-utils)
;;
nouveau)
pkgs=(xf86-video-nouveau)
;;
*)
echo "Unknown driver: $driver"
return 1
;;
esac
local missing=0
for pkg in "${pkgs[@]}"; do
if ! pacman -Q "$pkg" &>/dev/null; then
echo "Package $pkg is NOT installed."
missing=1
else
echo "Package $pkg is installed."
fi
done
if (( missing == 1 )); then
echo "Installing missing packages..."
sudo pacman -S --needed "${pkgs[@]}"
if [[ $? -ne 0 ]]; then
echo "Error installing packages. Aborting."
exit 1
fi
else
echo "All required packages are already installed."
fi
return 0
}
# Check and install packages if needed
check_driver_packages "$driver"
echo "NVIDIA driver setup completed."
break
elif [[ "$driver_answer" == "n" || "$driver_answer" == "N" ]]; then
echo "NVIDIA driver installation skipped."
break
else
echo "Please answer y (yes) or n (no)."
fi
done
# Install amd drivers
while true; do
echo "Install amd drivers? (y/n)"
read -r amd_answer
if [[ "$amd_answer" == "y" || "$amd_answer" == "Y" ]]; then
pacman -S --noconfirm --needed mesa lib32-mesa mesa-vdpau lib32-mesa-vdpau lib32-vulkan-radeon vulkan-radeon glu lib32-glu vulkan-icd-loader lib32-vulkan-icd-loader
echo "AMD drivers installed successfully."
break
elif [[ "$amd_answer" == "n" || "$amd_answer" == "N" ]]; then
echo "AMD river installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install Wine and Winetricks
while true; do
echo "Install Wine and Winetricks? (y/n)"
read -r wine_answer
if [[ "$wine_answer" =~ ^[Yy]$ ]]; then
pacman -S --noconfirm --needed wine-staging winetricks wine-mono
echo "Wine and Winetricks installed succesfully."
break
elif [[ "$wine_answer" =~ ^[Nn]$ ]]; then
echo "wine installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Installsystem monitoring tools
while true; do
echo "Install system monitoring tools (fastfetch/nvtop/htop/btop)? (y/n)"
read -r monitoring_answer
if [[ "$monitoring_answer" =~ ^[Yy]$ ]]; then
pacman -S --noconfirm --needed fastfetch nvtop htop btop
echo "System monitoring tools installed succesfully."
break
elif [[ "$monitoring_answer" =~ ^[Nn]$ ]]; then
echo "Monitoring tools installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install linutil
while true; do
echo "Install linutil for extra setup options ? (y/n)"
read -r linutil_answer
if [[ "$linutil_answer" =~ ^[Yy]$ ]]; then
sudo -u "$TARGET_USER" yay -S --noconfirm --needed linutil-bin
echo "Linutil installed succesfully."
break
elif [[ "$linutil_answer" =~ ^[Nn]$ ]]; then
echo "Linutil installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install lact
while true; do
echo "Install lact (manage and/or overclock your GPU)? (y/n)"
read -r lact_answer
if [[ "$lact_answer" =~ ^[Yy]$ ]]; then
pacman -S --noconfirm --needed lact
echo "lact installed succesfully."
break
elif [[ "$lact_answer" =~ ^[Nn]$ ]]; then
echo "lact installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install and configure Firewall
while true; do
echo "Install and configure Firewall(UFW)? (y/n)"
read -r ufw_answer
if [[ "$ufw_answer" =~ ^[Yy]$ ]]; then
pacman -S --noconfirm --needed ufw
systemctl enable ufw
echo "ufw installed succesfully."
break
elif [[ "$ufw_answer" =~ ^[Nn]$ ]]; then
echo "ufw installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install protonplus
while true; do
echo "Install protonplus (manage compatibility tools like PROTON)? (y/n)"
read -r proton_answer
if [[ "$proton_answer" =~ ^[Yy]$ ]]; then
sudo -u "$TARGET_USER" yay -S --noconfirm --needed protonplus
echo "protonplus installed succesfully."
break
elif [[ "$proton_answer" =~ ^[Nn]$ ]]; then
echo "proton installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install cachyos repos
while true; do
echo "Install cachyos repos for optimized packages? (y/n)"
read -r cachy_answer
if [[ "$cachy_answer" =~ ^[Yy]$ ]]; then
curl -O https://mirror.cachyos.org/cachyos-repo.tar.xz
tar xvf cachyos-repo.tar.xz && cd cachyos-repo
sudo ./cachyos-repo.sh
echo "cachy repos installed succesfully."
break
elif [[ "$cachy_answer" =~ ^[Nn]$ ]]; then
echo "cachy repos installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
# Install cachyos kernel
while true; do
echo "Install cachyos kernel? (y/n)"
read -r kernel_answer
if [[ "$kernel_answer" =~ ^[Yy]$ ]]; then
sudo -u "$TARGET_USER" yay -S --noconfirm --needed linux-cachyos linux-cachyos-headers
echo "Kernel installed succesfully."
break
elif [[ "kernel_answer" =~ ^[Nn]$ ]]; then
echo "Kernel installation skipped."
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done