-
Notifications
You must be signed in to change notification settings - Fork 1
/
fix-arch-linux.sh
95 lines (89 loc) · 4.72 KB
/
fix-arch-linux.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
#!/bin/bash
# Function to prompt for root password
prompt_for_root_password() {
read -rsp "Password: " ROOT_PASSWORD
echo ""
}
# Prompt for root password once
prompt_for_root_password
commands=("Fix 'failed to synchronize all databases' for Pacman" "Fix 'unable to lock database' for Pacman" "Fix 'unable to lock database' for Pamac" "Fix clock time" "Fix connectivity issues" "Fix corrupted PGP signatures" "Fix corrupted packages" "Fix DNSCrypt issues" "Fix GPG key errors" "Fix login issues" "Fix login issues [NVIDIA]" "See system logs" "Update system" "Quit")
selected=0
# Function to display the list and highlight the selected item
display_list() {
clear
echo -e "\033[1m Fix Arch Linux\033[0m\n --------------"
for i in $(seq 0 $((${#commands[@]} - 1))); do
if [ $i -eq $selected ]; then
if [ "${commands[$i]}" == "Quit" ]; then
echo -e "\033[1m➤ ${commands[$i]}\033[0m\n"
else
echo -e "\033[1m➤ ${commands[$i]}\033[0m\n"
fi
else
echo -e " ${commands[$i]}\n"
fi
done
}
# Function to execute the selected command
execute_command() {
case "${commands[$selected]}" in
"Fix 'failed to synchronize all databases' for Pacman")
echo "$ROOT_PASSWORD" | su -c 'rm -rf /var/lib/pacman/sync && rm -rf /var/tmp/pamac/dbs/sync && pacman -Sy'
read -p "Press Enter to return to the menu..."
;;
"Fix 'unable to lock database' for pacman")
echo "$ROOT_PASSWORD" | su -c 'rm /var/lib/pacman/db.lck'
read -p "Press Enter to return to the menu..."
;;
"Fix 'unable to lock database' for pamac")
echo "$ROOT_PASSWORD" | su -c 'rm /var/tmp/pamac/dbs/db.lck'
read -p "Press Enter to return to the menu..."
;;
"Fix clock time")
echo "$ROOT_PASSWORD" | su -c 'time_str=$(curl -sI "http://google.com" | grep -i "^date:" | cut -d' ' -f2-) && date -s "$time_str" &>/dev/null && hwclock --systohc &>/dev/null'
read -p "Press Enter to return to the menu..."
;;
"Fix Connectivity issues")
echo "$ROOT_PASSWORD" | su -c 'pacman -Rdd networkmanager --noconfirm && rm -rf /etc/NetworkManager && pacman -S networkmanager --noconfirm --needed && nmcli con add type ethernet ifname eth0 && reboot'
read -p "Press Enter to return to the menu..."
;;
"Fix corrupted PGP signatures")
echo "$ROOT_PASSWORD" | su -c 'pacman-key --refresh-keys'
read -p "Press Enter to return to the menu..."
;;
"Fix corrupted packages")
echo "$ROOT_PASSWORD" | su -c 'pacman -Qnq | xargs pacman -S --noconfirm --overwrite "*"'
read -p "Press Enter to return to the menu..."
;;
"Login issue fix")
echo "$ROOT_PASSWORD" | su -c 'update-grub && pacman -R --noconfirm linux linux-headers && pacman -S --noconfirm linux linux-headers'
read -p "Press Enter to return to the menu..."
;;
"Login issue fix [NVIDIA]")
echo "$ROOT_PASSWORD" | su -c 'pacman -R nvidia-dkms --noconfirm && pacman -S nvidia-dkms --noconfirm && pacman -R --noconfirm linux linux-headers && pacman -S --noconfirm linux linux-headers && update-grub'
read -p "Press Enter to return to the menu..."
;;
"Fix DNSCrypt issues")
echo "$ROOT_PASSWORD" | su -c 'pacman -Rdd dnscrypt-proxy --noconfirm && pacman -S dnscrypt-proxy --noconfirm && echo -e "# Generated by NetworkManager\nnameserver 127.0.0.1" | tee /etc/resolv.conf'
read -p "Press Enter to return to the menu..."
;;
"Fix GPG key errors")
echo "$ROOT_PASSWORD" | su -c 'mv /etc/pacman.d/gnupg{,.bak} && pacman-key --init && pacman-key --populate archlinux && pacman-key --populate artix && pacman-key --recv-key FBA220DFC880C036 --keyserver keyserver.ubuntu.com && pacman-key --lsign-key FBA220DFC880C036 && pacman -U --noconfirm --needed 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' && pacman-key --populate manjaro'
read -p "Press Enter to return to the menu..."
;;
"See system logs")
echo "$ROOT_PASSWORD" | su -c 'dmesg'
read -p "Press Enter to return to the menu..."
;;
"Update system")
echo "$ROOT_PASSWORD" | su -c 'pacman -Syyu --noconfirm && update-grub'
read -p "Press Enter to return to the menu..."
;;
"Quit")
exit 0
;;
*)
echo -e "\nInvalid selection"
;;
esac
}