-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·3329 lines (2923 loc) · 119 KB
/
install.sh
File metadata and controls
executable file
·3329 lines (2923 loc) · 119 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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗██╗ ██╗ ██████╗ ███████╗
# ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║ ██║╚██╗ ██╔╝██╔═══██╗██╔════╝
# ██║ ██║██████╔╝███████║██████╔╝███████║ ╚████╔╝ ██║ ██║███████╗
# ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║ ╚██╔╝ ██║ ██║╚════██║
# ██████╔╝██║ ██║██║ ██║██║ ██║ ██║ ██║ ╚██████╔╝███████║
# ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
#
# draphyOS Installer
# https://github.com/draphy/draphyOS
#
# Usage: git clone https://github.com/draphy/draphyOS ~/.draphyOS && ~/.draphyOS/install.sh
# ~/.draphyOS/install.sh --vm (for virtual machines)
#
# Options:
# --vm Force VM mode (use xrender backend for picom)
# --help Show help message
#
# Exit on undefined variable (but not on error - we handle those)
set -u
# Colors (with fallback for non-color terminals)
if [[ -t 1 ]] && [[ "${TERM:-dumb}" != "dumb" ]]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MINT='\033[38;2;154;184;124m' # Mint-Y green #9ab87c
NC='\033[0m'
else
RED=''
GREEN=''
YELLOW=''
BLUE=''
MINT=''
NC=''
fi
# Validate HOME directory exists and is writable
if [ -z "${HOME:-}" ]; then
echo "ERROR: HOME environment variable is not set"
exit 1
fi
if [ ! -d "$HOME" ]; then
echo "ERROR: HOME directory does not exist: $HOME"
exit 1
fi
if [ ! -w "$HOME" ]; then
echo "ERROR: HOME directory is not writable: $HOME"
exit 1
fi
# Variables
REPO_URL="https://github.com/draphy/draphyOS.git"
INSTALL_DIR="$HOME/.draphyOS"
BACKUP_DIR="$HOME/.config-backup-$(date +%Y%m%d-%H%M%S)"
MARKER_FILE="$HOME/.draphyOS-installed"
LOCK_FILE="/tmp/draphyOS-install-$UID.lock"
LOG_FILE="/tmp/draphyOS-install.log"
# Hardware detection results (populated by configure_hardware, written by create_marker)
IS_VM_MODE="false"
# Command line flags
FORCE_VM_MODE="false"
# Failed items tracking (displayed at end of installation)
FAILED_ITEMS=()
# Discover all config files in the repo's configs/ directory
# Returns relative paths (e.g., "i3/config", "fish/config.fish")
# Used by symlink creation, backup, checksums — ensures new files are auto-handled
get_all_config_files() {
local configs_dir="$INSTALL_DIR/configs"
if [ ! -d "$configs_dir" ]; then
return
fi
find "$configs_dir" -type f -printf '%P\n' 2>/dev/null | sort
}
# Map a config name (relative path) to the user's file path
get_user_config_path() {
local config_name="$1"
case "$config_name" in
xprofile)
echo "$HOME/.xprofile"
;;
*)
echo "$HOME/.config/$config_name"
;;
esac
}
# Helper functions for pre-check and post-verify
check_package_installed() {
local pkg="$1"
rpm -q "$pkg" &>/dev/null
}
check_command_exists() {
local cmd="$1"
command -v "$cmd" &>/dev/null
}
verify_package() {
local cmd="$1"
local name="$2"
if command -v "$cmd" &>/dev/null; then
print_success "$name installed successfully"
return 0
else
print_error "$name installation failed"
FAILED_ITEMS+=("$name")
return 1
fi
}
verify_service() {
local service="$1"
if systemctl is-active --quiet "$service"; then
print_success "$service is running"
return 0
else
print_error "$service is not running"
FAILED_ITEMS+=("$service")
return 1
fi
}
# Cleanup function
cleanup() {
local exit_code=$?
# Remove lock (handles both file and directory)
rm -rf "$LOCK_FILE" 2>/dev/null || true
# Kill sudo keeper if running (validate PID is numeric first)
if [ -n "${SUDO_KEEPER_PID:-}" ] && [[ "${SUDO_KEEPER_PID}" =~ ^[0-9]+$ ]]; then
kill "$SUDO_KEEPER_PID" 2>/dev/null || true
wait "$SUDO_KEEPER_PID" 2>/dev/null || true
fi
return $exit_code
}
trap cleanup EXIT
trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM
# Safe user input (handles non-TTY environments)
# Usage: ask_user "prompt" "default" -> sets REPLY variable
ask_user() {
local prompt="$1"
local default="${2:-n}"
echo -e "$prompt"
if [ -t 0 ] || [ -e /dev/tty ]; then
read -r REPLY </dev/tty 2>/dev/null || REPLY="$default"
else
# Non-interactive: use default
REPLY="$default"
echo "(Non-interactive mode, using default: $default)"
fi
# Normalize empty response to default
[ -z "$REPLY" ] && REPLY="$default"
}
# Print functions
print_header() {
echo ""
echo -e "${MINT}"
echo " ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗██╗ ██╗ ██████╗ ███████╗"
echo " ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║ ██║╚██╗ ██╔╝██╔═══██╗██╔════╝"
echo " ██║ ██║██████╔╝███████║██████╔╝███████║ ╚████╔╝ ██║ ██║███████╗"
echo " ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║ ╚██╔╝ ██║ ██║╚════██║"
echo " ██████╔╝██║ ██║██║ ██║██║ ██║ ██║ ██║ ╚██████╔╝███████║"
echo " ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝"
echo -e "${NC}"
echo -e " Installer"
echo ""
}
print_step() {
echo -e "${GREEN}[*]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[!]${NC} $1"
}
print_error() {
echo -e "${RED}[✗]${NC} $1"
}
print_success() {
echo -e "${GREEN}[✓]${NC} $1"
}
# Check if another instance is running (atomic lock using mkdir)
check_lock() {
local lock_dir="/tmp/draphyOS-install-$UID.lock.d"
# Try to create lock directory atomically
if mkdir "$lock_dir" 2>/dev/null; then
# Successfully acquired lock, save PID
echo $$ > "$lock_dir/pid"
LOCK_FILE="$lock_dir"
return 0
fi
# Lock exists - check if stale
if [ -f "$lock_dir/pid" ]; then
local pid
pid=$(cat "$lock_dir/pid" 2>/dev/null)
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
print_error "Another installation is already running (PID: $pid)"
exit 1
fi
fi
# Stale lock - remove and retry
rm -rf "$lock_dir" 2>/dev/null
if mkdir "$lock_dir" 2>/dev/null; then
echo $$ > "$lock_dir/pid"
LOCK_FILE="$lock_dir"
return 0
fi
print_error "Could not acquire lock"
exit 1
}
# Check required commands
check_requirements() {
print_step "Checking requirements..."
local missing=()
local optional_missing=()
# Check for required commands
for cmd in git sudo dnf timeout; do
if ! command -v "$cmd" &>/dev/null; then
missing+=("$cmd")
fi
done
# Check for optional but recommended commands
for cmd in xrandr ip ping; do
if ! command -v "$cmd" &>/dev/null; then
optional_missing+=("$cmd")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
print_error "Missing required commands: ${missing[*]}"
print_error "Please install them first: sudo dnf install ${missing[*]}"
exit 1
fi
if [ ${#optional_missing[@]} -gt 0 ]; then
print_warning "Optional commands not found: ${optional_missing[*]}"
print_warning "Some features may not work correctly."
fi
print_success "All requirements met"
}
# Check internet connection
check_internet() {
print_step "Checking internet connection..."
local connected=false
# Try multiple methods to check connectivity
# Method 1: curl to GitHub (most reliable for our use case)
if command -v curl &>/dev/null; then
if curl -sfI --connect-timeout 5 --max-time 10 https://github.com &>/dev/null; then
connected=true
fi
fi
# Method 2: ping GitHub (may be blocked in some networks)
if [ "$connected" = false ] && command -v ping &>/dev/null; then
if ping -c 1 -W 5 github.com &>/dev/null; then
connected=true
fi
fi
# Method 3: DNS lookup (check if DNS works)
if [ "$connected" = false ] && command -v host &>/dev/null; then
if host github.com &>/dev/null; then
connected=true
fi
fi
# Method 4: ping fallback IP
if [ "$connected" = false ] && command -v ping &>/dev/null; then
if ping -c 1 -W 5 8.8.8.8 &>/dev/null || ping -c 1 -W 5 1.1.1.1 &>/dev/null; then
print_warning "Internet detected but GitHub may not be reachable"
connected=true
fi
fi
if [ "$connected" = false ]; then
print_error "No internet connection detected"
print_error "Please connect to the internet and try again"
exit 1
fi
print_success "Internet connection OK"
}
# Check sudo access
check_sudo() {
print_step "Checking sudo access..."
if ! sudo -v &>/dev/null; then
print_error "Sudo access required. Please run with a user that has sudo privileges."
exit 1
fi
# Keep sudo alive in background (with error handling)
(while true; do sudo -v 2>/dev/null || break; sleep 50; done) &
SUDO_KEEPER_PID=$!
# Note: cleanup trap already handles SUDO_KEEPER_PID
print_success "Sudo access OK"
}
# Check if running on Fedora
check_fedora() {
print_step "Checking operating system..."
if [ ! -f /etc/fedora-release ]; then
print_error "This installer is designed for Fedora"
local detected_os="Unknown"
if [ -f /etc/os-release ]; then
detected_os=$(grep -m1 "^PRETTY_NAME=" /etc/os-release 2>/dev/null | cut -d= -f2 | tr -d '"')
fi
print_error "Detected OS: ${detected_os:-Unknown}"
exit 1
fi
FEDORA_VERSION=$(rpm -E %fedora 2>/dev/null || echo "unknown")
print_success "Fedora $FEDORA_VERSION detected"
}
# Check if already installed
check_installed() {
if [ -f "$MARKER_FILE" ]; then
print_warning "draphyOS is already installed."
echo -e "Do you want to ${YELLOW}update/reinstall${NC}? (y/n)"
read -r response </dev/tty || response="n"
if [[ ! "$response" =~ ^[Yy](es)?$ ]]; then
echo "Exiting."
exit 0
fi
print_step "Proceeding with reinstall..."
fi
}
# Verify and update repo
setup_repo() {
print_step "Verifying draphyOS files..."
# Repo must exist (user clones first)
if [ ! -d "$INSTALL_DIR" ]; then
print_error "draphyOS not found at $INSTALL_DIR"
print_error "Please clone first: git clone https://github.com/draphy/draphyOS ~/.draphyOS"
exit 1
fi
if [ ! -d "$INSTALL_DIR/.git" ]; then
print_error "$INSTALL_DIR is not a git repository"
print_error "Please clone properly: git clone https://github.com/draphy/draphyOS ~/.draphyOS"
exit 1
fi
# Try to update (non-fatal if offline)
if cd "$INSTALL_DIR"; then
if timeout 60 git fetch --quiet origin 2>/dev/null; then
local default_branch
default_branch=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
default_branch="${default_branch:-main}"
if git reset --hard "origin/$default_branch" --quiet 2>/dev/null; then
print_step "Updated to latest version"
fi
else
print_warning "Could not check for updates (offline?). Using existing files."
fi
fi
# Verify essential files exist
local essential_files=(
"$INSTALL_DIR/configs/i3/config"
"$INSTALL_DIR/configs/polybar/config.ini"
"$INSTALL_DIR/configs/fish/config.fish"
"$INSTALL_DIR/configs/environment.d/defaults.conf"
"$INSTALL_DIR/update.sh"
)
local missing_count=0
for file in "${essential_files[@]}"; do
if [ ! -f "$file" ]; then
print_error "Missing essential file: $file"
((missing_count++))
fi
done
if [ $missing_count -gt 0 ]; then
print_error "Installation files are incomplete ($missing_count files missing)."
print_error "Please re-clone: rm -rf ~/.draphyOS && git clone https://github.com/draphy/draphyOS ~/.draphyOS"
exit 1
fi
print_success "draphyOS files verified"
}
# Add RPMFusion repositories (required for many media packages)
add_rpmfusion() {
if dnf repolist | grep -qi rpmfusion; then
print_step "RPMFusion already configured"
return 0
fi
print_step "Adding RPMFusion repositories..."
# Install both free and nonfree repos
if ! sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"; then
print_error "Failed to add RPMFusion repositories"
FAILED_ITEMS+=("rpmfusion")
return 1
fi
# Enable Cisco OpenH264 for Firefox (Fedora 41+)
sudo dnf config-manager setopt fedora-cisco-openh264.enabled=1 2>/dev/null || true
# Verify installation
if dnf repolist | grep -qi rpmfusion; then
print_success "RPMFusion configured"
else
print_error "RPMFusion setup failed"
FAILED_ITEMS+=("rpmfusion")
return 1
fi
}
# Setup third-party repositories (Brave, Chrome, VS Code, ProtonVPN, Docker, yazi, ueberzugpp)
setup_third_party_repos() {
print_step "Setting up third-party repositories..."
# =========================================================================
# PRELIMINARY: Check if we can reach package repositories
# =========================================================================
local repo_connectivity=true
if ! curl -sfI --connect-timeout 5 --max-time 10 https://dl.google.com &>/dev/null; then
print_warning "Some package repositories may be unreachable"
repo_connectivity=false
fi
# =========================================================================
# BRAVE BROWSER
# =========================================================================
if [ ! -f /etc/yum.repos.d/brave-browser.repo ]; then
print_step "Adding Brave repository..."
if ! sudo dnf config-manager addrepo --from-repofile=https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo 2>/dev/null; then
# Fallback: create repo file manually
if cat << 'EOF' | sudo tee /etc/yum.repos.d/brave-browser.repo > /dev/null 2>&1
[brave-browser]
name=Brave Browser
baseurl=https://brave-browser-rpm-release.s3.brave.com/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
EOF
then
sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc 2>/dev/null || true
print_step "Brave repo added (manual fallback)"
else
print_warning "Failed to add Brave repo"
FAILED_ITEMS+=("brave-repo")
fi
fi
fi
# Google Chrome
if [ ! -f /etc/yum.repos.d/google-chrome.repo ]; then
print_step "Adding Google Chrome repository..."
# Import Google's signing key first
sudo rpm --import https://dl.google.com/linux/linux_signing_key.pub 2>/dev/null || true
# Create repo file manually (more reliable than addrepo)
if ! cat << 'EOF' | sudo tee /etc/yum.repos.d/google-chrome.repo > /dev/null
[google-chrome]
name=Google Chrome
baseurl=https://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF
then
print_warning "Failed to add Google Chrome repo"
FAILED_ITEMS+=("chrome-repo")
fi
fi
# VS Code
if [ ! -f /etc/yum.repos.d/vscode.repo ]; then
print_step "Adding VS Code repository..."
if ! sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc 2>/dev/null; then
print_warning "Failed to import Microsoft GPG key"
fi
if ! cat << 'EOF' | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
then
print_error "Failed to create VS Code repo file"
FAILED_ITEMS+=("vscode-repo")
fi
# Verify repo was created
if [ ! -f /etc/yum.repos.d/vscode.repo ]; then
print_error "VS Code repo file not found after creation"
FAILED_ITEMS+=("vscode-repo-verify")
fi
fi
# ProtonVPN
if ! rpm -q protonvpn-stable-release &>/dev/null; then
print_step "Adding ProtonVPN repository..."
local fedora_ver
fedora_ver=$(rpm -E %fedora)
if curl -fsSL "https://repo.protonvpn.com/fedora-${fedora_ver}-stable/protonvpn-stable-release/protonvpn-stable-release-1.0.3-1.noarch.rpm" -o /tmp/protonvpn-repo.rpm; then
if sudo dnf install /tmp/protonvpn-repo.rpm -y 2>/dev/null; then
rm -f /tmp/protonvpn-repo.rpm
# Verify repo was installed
if rpm -q protonvpn-stable-release &>/dev/null; then
print_step "ProtonVPN repo installed (verified)"
else
print_warning "ProtonVPN repo package not found after install"
FAILED_ITEMS+=("protonvpn-repo-verify")
fi
else
print_warning "Failed to install ProtonVPN repo"
FAILED_ITEMS+=("protonvpn-repo-install")
rm -f /tmp/protonvpn-repo.rpm
fi
else
print_warning "Failed to download ProtonVPN repo"
FAILED_ITEMS+=("protonvpn-repo")
fi
else
print_step "ProtonVPN repo already installed"
fi
# Docker
if [ ! -f /etc/yum.repos.d/docker-ce.repo ]; then
print_step "Adding Docker repository..."
sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo || {
print_warning "Failed to add Docker repo"
FAILED_ITEMS+=("docker-repo")
}
fi
# yazi COPR
if ! dnf repolist | grep -q "copr:copr.fedorainfracloud.org:lihaohong:yazi"; then
print_step "Enabling yazi COPR..."
sudo dnf copr enable lihaohong/yazi -y 2>/dev/null || {
print_warning "Failed to enable yazi COPR"
FAILED_ITEMS+=("yazi-copr")
}
fi
# ueberzugpp OBS (for yazi image preview)
if [ ! -f /etc/yum.repos.d/home:justkidding.repo ] && [ ! -f /etc/yum.repos.d/home_justkidding.repo ]; then
print_step "Adding ueberzugpp OBS repository..."
local fedora_ver
fedora_ver=$(rpm -E %fedora)
# Note: URL uses home:/justkidding (colon-slash) format
local obs_url="https://download.opensuse.org/repositories/home:/justkidding/Fedora_${fedora_ver}/home:justkidding.repo"
# Check if repo exists for this Fedora version
if curl -sLf "$obs_url" -o /tmp/ueberzugpp.repo 2>/dev/null; then
if sudo cp /tmp/ueberzugpp.repo /etc/yum.repos.d/home_justkidding.repo; then
rm -f /tmp/ueberzugpp.repo
print_step "ueberzugpp repo added"
else
rm -f /tmp/ueberzugpp.repo
print_warning "Failed to add ueberzugpp repo"
FAILED_ITEMS+=("ueberzugpp-repo")
fi
else
# Try Fedora 41 as fallback
local fallback_url="https://download.opensuse.org/repositories/home:/justkidding/Fedora_41/home:justkidding.repo"
if curl -sLf "$fallback_url" -o /tmp/ueberzugpp.repo 2>/dev/null; then
print_step "Using Fedora 41 repo as fallback for ueberzugpp..."
if sudo cp /tmp/ueberzugpp.repo /etc/yum.repos.d/home_justkidding.repo; then
rm -f /tmp/ueberzugpp.repo
print_step "ueberzugpp repo added (Fedora 41 fallback)"
else
rm -f /tmp/ueberzugpp.repo
print_warning "Failed to add ueberzugpp repo (fallback)"
FAILED_ITEMS+=("ueberzugpp-repo")
fi
else
print_warning "ueberzugpp repo not available for Fedora $fedora_ver (optional)"
FAILED_ITEMS+=("ueberzugpp-repo")
fi
fi
fi
# Post-verification: check repos are usable
print_step "Verifying third-party repositories..."
local repo_errors=0
# Check that added repos appear in dnf repolist (quick verification)
local repolist
repolist=$(dnf repolist 2>/dev/null)
# Verify key repos are present (only if we added them)
if [ -f /etc/yum.repos.d/brave-browser.repo ]; then
if ! echo "$repolist" | grep -qi "brave"; then
print_warning "Brave repository added but not detected in repolist"
FAILED_ITEMS+=("brave-repo-verify")
((repo_errors++))
fi
fi
if [ -f /etc/yum.repos.d/vscode.repo ]; then
if ! echo "$repolist" | grep -qi "code"; then
print_warning "VS Code repository added but not detected in repolist"
FAILED_ITEMS+=("vscode-repo-verify")
((repo_errors++))
fi
fi
if [ -f /etc/yum.repos.d/docker-ce.repo ]; then
if ! echo "$repolist" | grep -qi "docker"; then
print_warning "Docker repository added but not detected in repolist"
FAILED_ITEMS+=("docker-repo-verify")
((repo_errors++))
fi
fi
if [ $repo_errors -gt 0 ]; then
print_warning "Third-party repositories configured with $repo_errors verification issue(s)"
else
print_success "Third-party repositories configured (verified)"
fi
# Refresh DNF cache after adding repos (critical for new repos to work)
print_step "Refreshing package cache..."
if ! sudo dnf makecache --refresh 2>&1 | tee -a "$LOG_FILE"; then
print_warning "DNF cache refresh had issues, continuing anyway..."
fi
}
# Save current package state (for clean uninstall later)
save_package_state() {
print_step "Saving current package state..."
local pkg_state_file="$HOME/.draphyOS-packages-before"
# Use rpm -qa for reliable package listing (works across DNF4/DNF5)
# Output just package names without version/arch
if ! rpm -qa --qf '%{NAME}\n' 2>/dev/null | sort -u > "$pkg_state_file"; then
print_warning "Failed to save package state"
FAILED_ITEMS+=("package-state-save")
return 1
fi
# Verify the file was created and has reasonable content
if [ -f "$pkg_state_file" ] && [ -s "$pkg_state_file" ]; then
local count
count=$(wc -l < "$pkg_state_file")
# A minimal Fedora system has at least 500+ packages
if [ "$count" -ge 100 ]; then
print_success "Package state saved ($count packages, verified)"
else
print_warning "Package state seems incomplete ($count packages)"
FAILED_ITEMS+=("package-state-incomplete")
fi
else
print_warning "Could not save package state"
FAILED_ITEMS+=("package-state-verify")
fi
}
# Install packages
install_packages() {
print_step "Installing required packages..."
# Remove redshift if installed (replaced by gammastep in v10)
if rpm -q redshift &>/dev/null; then
print_step "Removing redshift (replaced by gammastep)..."
sudo dnf remove -y redshift geoclue2 2>/dev/null || true
fi
# Packages based on official Fedora i3 Spin + draphyOS customizations
PACKAGES=(
# === Core ===
git # Needed first for repo operations
i3 i3lock dunst lightdm
# Terminal
alacritty
# Networking
NetworkManager network-manager-applet firefox
# Audio
pulseaudio-utils pavucontrol
# Utilities
brightnessctl htop mousepad Thunar
# App launcher
rofi
# Productivity & GUI tools
lxappearance powertop arandr tmux
# === draphyOS Customizations ===
# Shell
fish
# Status bar
polybar
# Compositor
picom
# Utilities
feh flameshot playerctl xss-lock
ImageMagick xdotool xclip
# Bluetooth
blueman
# Authentication
xfce-polkit gnome-keyring
# Theming
xfce4-settings
# Night light (gammastep replaces redshift in v10)
gammastep
# Fonts
fira-code-fonts google-noto-sans-mono-vf-fonts
fontawesome-6-free-fonts fontawesome-6-brands-fonts
# Icons & Themes
mint-y-icons adwaita-cursor-theme
# Calendar popup
yad
# Qt theming
qt5ct
# === v10 Additions ===
# Third-party apps (repos added by setup_third_party_repos)
brave-browser
google-chrome-stable
code
proton-vpn-gnome-desktop
# Docker
docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# yazi file manager (COPR)
yazi
# Note: ueberzugpp installed separately (OBS repo may not be available)
# Media
torbrowser-launcher
neovim
obs-studio kdenlive mpv audacious
# Documents
zathura zathura-pdf-poppler
libreoffice-writer libreoffice-calc libreoffice-impress libreoffice-draw
# System tools
gparted btop
# CLI tools
zoxide ffmpeg p7zip jq poppler-utils
fd-find ripgrep fzf ffmpegthumbnailer atool
# Database
postgresql-server postgresql-contrib
)
print_step "This may take a few minutes..."
# Handle ffmpeg conflict (ffmpeg-free vs ffmpeg from RPMFusion)
# RPMFusion's ffmpeg has more codecs, so prefer it
if rpm -q ffmpeg-free &>/dev/null; then
print_step "Replacing ffmpeg-free with full ffmpeg from RPMFusion..."
if sudo dnf swap -y ffmpeg-free ffmpeg --allowerasing 2>&1 | tee -a "$LOG_FILE"; then
if rpm -q ffmpeg &>/dev/null && ! rpm -q ffmpeg-free &>/dev/null; then
print_step "ffmpeg swap successful"
else
print_warning "ffmpeg swap may not have completed correctly"
fi
else
print_warning "ffmpeg swap failed, continuing with ffmpeg-free"
fi
fi
# Install all packages with --allowerasing to handle conflicts
# Use retry logic for network failures
print_step "Installing packages (this may take several minutes)..."
local install_retries=3
local install_success=false
while [ $install_retries -gt 0 ]; do
# Configure DNF for better network handling
# Use subshell to capture exit code properly while still logging
local dnf_exit=0
(
set -o pipefail
sudo dnf install -y "${PACKAGES[@]}" \
--skip-unavailable \
--allowerasing \
--setopt=install_weak_deps=False \
--setopt=timeout=60 \
--setopt=retries=5 \
--setopt=minrate=1000 \
2>&1 | tee -a "$LOG_FILE"
) || dnf_exit=$?
if [ "$dnf_exit" -eq 0 ]; then
install_success=true
break
fi
# Check if it's a network error (exit code 1 with curl/timeout in log)
if grep -qE "Curl error|Timeout|Connection|Failed to download" "$LOG_FILE" 2>/dev/null; then
((install_retries--))
if [ $install_retries -gt 0 ]; then
print_warning "Network error detected, retrying in 5 seconds... ($install_retries attempts left)"
sleep 5
# Clear DNF cache on retry
sudo dnf clean metadata 2>/dev/null || true
fi
else
# Not a network error, don't retry
break
fi
done
if [ "$install_success" = false ]; then
print_warning "Some packages may have failed. Continuing anyway..."
fi
# Try to install ueberzugpp separately (optional, for yazi image preview)
if [ -f /etc/yum.repos.d/home:justkidding.repo ]; then
print_step "Installing ueberzugpp (optional)..."
sudo dnf install -y ueberzugpp 2>/dev/null || {
print_warning "ueberzugpp not available (yazi image preview disabled)"
}
fi
# Verify critical packages are installed
print_step "Verifying critical packages..."
local CRITICAL_PACKAGES=(
"i3:i3"
"polybar:polybar"
"fish:fish"
"rofi:rofi"
"alacritty:alacritty"
"picom:picom"
"dunst:dunst"
"feh:feh"
"gammastep:gammastep"
"lightdm:lightdm"
)
local failed_count=0
for pkg_cmd in "${CRITICAL_PACKAGES[@]}"; do
local pkg="${pkg_cmd%%:*}"
local cmd="${pkg_cmd##*:}"
if ! rpm -q "$pkg" &>/dev/null && ! command -v "$cmd" &>/dev/null; then
print_error "Critical package not installed: $pkg"
FAILED_ITEMS+=("pkg-$pkg")
((failed_count++))
fi
done
if [ $failed_count -eq 0 ]; then
print_success "All critical packages verified"
else
print_warning "$failed_count critical packages missing"
fi
# Verify theme packages
print_step "Verifying theme packages..."
local THEME_PACKAGES=(
"mint-y-icons"
"adwaita-cursor-theme"
"fira-code-fonts"
"fontawesome-6-free-fonts"
)
local theme_failed=0
for pkg in "${THEME_PACKAGES[@]}"; do
if ! rpm -q "$pkg" &>/dev/null; then
print_warning "Theme package not installed: $pkg"
FAILED_ITEMS+=("theme-$pkg")
((theme_failed++))
fi
done
if [ $theme_failed -eq 0 ]; then
print_success "All theme packages verified"
else
print_warning "$theme_failed theme packages missing (visual issues possible)"
fi
# Verify font files exist
if ! command -v fc-list &>/dev/null; then
print_warning "fontconfig tools not available, skipping font verification"
elif fc-list 2>/dev/null | grep -qi "fira code"; then
print_step "Fira Code font verified"
else
print_warning "Fira Code font not found in font cache"
FAILED_ITEMS+=("font-fira-code")
fi
# Verify icon theme exists
if [ -d /usr/share/icons/Mint-Y ] || [ -d "$HOME/.icons/Mint-Y" ]; then
print_step "Mint-Y icon theme verified"
else
print_warning "Mint-Y icon theme not found"
FAILED_ITEMS+=("icons-mint-y")
fi
# Verify third-party applications (optional but reported)
print_step "Verifying third-party applications..."
local THIRD_PARTY_APPS=(
"brave-browser:brave-browser"
"google-chrome-stable:google-chrome"
"code:code"
"docker-ce:docker"
"yazi:yazi"
)
local apps_installed=0
local apps_missing=0
for app_cmd in "${THIRD_PARTY_APPS[@]}"; do
local pkg="${app_cmd%%:*}"
local cmd="${app_cmd##*:}"
if rpm -q "$pkg" &>/dev/null || command -v "$cmd" &>/dev/null; then
((apps_installed++))
else
print_warning "Third-party app not installed: $pkg (optional)"
FAILED_ITEMS+=("app-$pkg")
((apps_missing++))
fi
done
if [ $apps_missing -eq 0 ]; then
print_success "All third-party apps verified ($apps_installed installed)"
else
print_warning "$apps_missing third-party apps missing (optional, can install later)"
fi
# Verify CLI tools
print_step "Verifying CLI tools..."
local CLI_TOOLS=(
"zoxide:zoxide"
"fzf:fzf"
"ripgrep:rg"
"fd-find:fd"
"jq:jq"
"btop:btop"
"neovim:nvim"
)
local cli_installed=0
local cli_missing=0
for tool_cmd in "${CLI_TOOLS[@]}"; do
local pkg="${tool_cmd%%:*}"
local cmd="${tool_cmd##*:}"
if rpm -q "$pkg" &>/dev/null || command -v "$cmd" &>/dev/null; then
((cli_installed++))
else
print_warning "CLI tool not installed: $pkg"
FAILED_ITEMS+=("cli-$pkg")
((cli_missing++))
fi
done
if [ $cli_missing -eq 0 ]; then
print_success "All CLI tools verified ($cli_installed installed)"
else
print_warning "$cli_missing CLI tools missing"
fi
# Verify media & document applications
print_step "Verifying media & document applications..."
local MEDIA_DOC_APPS=(
"mpv:mpv"
"audacious:audacious"
"obs-studio:obs"
"kdenlive:kdenlive"
"zathura:zathura"
"libreoffice-writer:libreoffice"
"libreoffice-calc:libreoffice"
"libreoffice-impress:libreoffice"