Skip to content

Commit

Permalink
Check if a pending kernel update requires a reboot to be applied
Browse files Browse the repository at this point in the history
This commit aims to add a new function to the script which checks if there's a pending kernel update requiring a reboot to be applied and, if so, offers to reboot
This function is, obviously, executed as the latest action of all the update/maintainenance steps of the script
  • Loading branch information
Antiz96 committed Dec 1, 2023
1 parent b2d5e96 commit afdc6d2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ update() {

orphan_packages
pacnew_files
reboot_kernel

read -n 1 -r -s -p $'Press \"enter\" to quit\n'
}

# Definition of the orphan_packages function: Print orphan packages and offer to remove them if there are (used in the "list_packages" and "update" functions)
Expand Down Expand Up @@ -289,8 +292,27 @@ pacnew_files() {
else
echo -e "No pacnew file found\n"
fi

read -n 1 -r -s -p $'Press \"enter\" to quit\n'
}

# Definition of the kernel_reboot function: Verify if there's a kernel update waiting for a reboot to be applied
kernel_reboot() {
kernel_compare=$(file /boot/vmlinuz* | sed 's/^.*version\ //' | awk '{print $1}' | grep $(uname -r))

if [ -z "${kernel_compare}" ]; then
echo -e "--Reboot required--\nThere's a pending kernel update on your system requiring a reboot to be applied"
read -rp $'Would you like to reboot now? [y/N] ' answer

case "${answer}" in
[Yy])
echo -e "\nRebooting in 5 seconds...\nPress ctrl+c to abort"
sleep 5
"${su_cmd}" reboot
;;
*)
echo -e "\nThe reboot hasn't been performed\nPlease, consider rebooting to finalize the pending kernel update\n"
;;
esac
fi
}

# Definition of the check function: Check for available updates, change the icon accordingly and send a desktop notification containing the number of available updates
Expand Down

0 comments on commit afdc6d2

Please sign in to comment.