-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
67 lines (52 loc) · 1.81 KB
/
update.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
#!/bin/bash
# Update package lists and upgrade installed packages
sudo dnf update
sudo dnf upgrade
# Refresh package cache and update again
sudo dnf --refresh update
# Install necessary packages for system upgrade
sudo dnf install dnf-plugin-system-upgrade
sudo dnf install rpmconf
# Detect and merge configuration files for updated packages
sudo rpmconf -a
# Download Fedora 39 release files
sudo dnf system-upgrade download --releasever=40
# Install tool for removing retired packages
sudo dnf install remove-retired-packages
remove-retired-packages
# Check for unsatisfied dependencies and remove duplicate packages
sudo dnf repoquery --unsatisfied
sudo dnf remove --duplicates
# List and remove extra packages (excluding kernel)
sudo dnf list extras
sudo dnf remove $(sudo dnf repoquery --extras --exclude=kernel,kernel-\*)
sudo dnf autoremove
# Remove old kernels
old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q))
if [ "${#old_kernels[@]}" -eq 0 ]; then
echo "No old kernels found"
else
if ! sudo dnf remove "${old_kernels[@]}"; then
echo "Failed to remove old kernels"
exit 1
else
echo "Removed old kernels"
fi
fi
# Install symlinks and remove dangling ones
sudo dnf install symlinks
sudo symlinks -r /usr | grep dangling
sudo symlinks -r -d /usr
# Remove rescue kernel images and perform kernel-related tasks
sudo rm /boot/*rescue*
sudo kernel-install add "$(uname -r)" "/lib/modules/$(uname -r)/vmlinuz"
sudo dnf install dracut-config-rescue
# Rebuild rpm database and synchronize distribution packages
sudo rpm --rebuilddb
sudo dnf distro-sync
sudo dnf distro-sync --allowerasing
# Set SELinux context on boot
sudo fixfiles -B onboot
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql
# Reboot the system for the upgrade to take effect
sudo dnf system-upgrade reboot