-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdetect.sh
More file actions
executable file
·64 lines (53 loc) · 1.74 KB
/
detect.sh
File metadata and controls
executable file
·64 lines (53 loc) · 1.74 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
#!/bin/bash
# CodeVerse Linux Installer - Detection Module
# System detection functions
# Detect boot mode (UEFI or BIOS)
detect_boot_mode() {
step_header "Detecting System"
gum spin --spinner dot --title "Checking boot mode..." -- sleep 0.5
if [[ -d /sys/firmware/efi/efivars ]]; then
BOOT_MODE="uefi"
gum style --foreground 82 " ✓ Boot mode: UEFI"
else
BOOT_MODE="bios"
gum style --foreground 208 " ● Boot mode: BIOS/Legacy"
fi
}
# List available disks
list_disks() {
lsblk -dno NAME,SIZE,MODEL | grep -vE "^(loop|sr|rom|fd|zram)"
}
# Get disk names only
get_disk_names() {
lsblk -dno NAME | grep -vE "^(loop|sr|rom|fd|zram)"
}
# Get partition name based on disk type
get_partition_name() {
local disk=$1
local part_num=$2
if [[ "$disk" == *"nvme"* ]] || [[ "$disk" == *"mmcblk"* ]]; then
echo "${disk}p${part_num}"
else
echo "${disk}${part_num}"
fi
}
# Check network connectivity
check_network() {
if ! gum spin --spinner dot --title "Checking network..." -- ping -c 1 -W 5 archlinux.org; then
gum style --foreground 208 " ● Network: not connected"
gum style --faint " Attempting to connect..."
systemctl start NetworkManager 2>/dev/null || true
sleep 3
for iface in $(ip -o link show | awk -F': ' '{print $2}' | grep -v lo); do
dhcpcd "$iface" 2>/dev/null &
done
sleep 5
if ! ping -c 1 -W 5 archlinux.org &>/dev/null; then
gum style --foreground 196 " ✗ No network connection"
gum style --faint " Use 'nmtui' or 'nmcli' to configure network"
return 1
fi
fi
gum style --foreground 82 " ✓ Network: connected"
return 0
}