You are not logged in.

#1 2023-12-14 14:26:47

MAYBL8
Member
Registered: 2022-01-14
Posts: 254

Kernel Load script and some utilities

I have created a little script to help me with some kernel installs and some utilities centered around GRUB.
This is the first version. I will add updates as I go.

Future mods would be to make it more user friendly i.e. handling errors
   I want to script removal of kernels but make it a choice of what kernels are installed.
   This might be better as a python script as it gets more complicated.
   Maybe a better name for the script.

I am not a script expert so I am sure there are better ways to make the code.
Anyway here it is if anyone is interested.
Thanks

#!/usr/bin/env bash
# version 1.0.0

PS3='Please enter your choice: '
options=("Linux Kernel" "lts kernel" "zen kernel" "hardened kernel" "rt kernel" "rt-lts kernel"
"rewrite grub" "List orphaned packages" "List Installed Kernels" "Edit default GRUB file" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Linux Kernel")
            echo "you chose Linux Kernel"
	    yes | sudo pacman -S linux linux-headers
	    sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot	
            ;;
        "lts kernel")
            echo "you chose lts kernel"
	    yes | sudo pacman -S linux-lts linux-lts-headers
	    sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
            ;;
        "zen kernel")
            echo "you chose choice $REPLY which is $opt"
	    yes | sudo pacman -S linux-zen linux-zen-headers
            sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
            ;;
	"hardened kernel")
	    echo "you chose choice $REPLY which is $opt"
	    yes | sudo pacman -S linux-hardened linux-hardened-headers
            sudo grub-mkconfig -o /boot/grub/grub.cfg    	
	    sudo reboot
	    ;;
	"rt kernel")
	    echo "you chose choice $REPLY which is $opt"
	    yes | sudo pacman -S linux-rt linux-rt-headers
            sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
	    ;;
	"rt-lts kernel")
	    echo "you chose choice $REPLY which is $opt"
	    yes | sudo pacman -S linux-rt-lts linux-rt-lts-headers
            sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
	    ;;
	"rewrite grub")
	    echo "you chose choice $REPLY which is $opt"
	    sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
	    ;;
	"List orphaned packages")
	    echo "you chose choice $REPLY which is $opt"
	    echo " "
	    echo "WARNING! Please review this list carefully before proceeding to the next step. It is important to remove only the necessary packages as some of them may be critical and could cause issues if removed accidentally. Always keep verified backups."
	    sudo pacman -Qqd | pacman -Rsu --print -
#	    sudo pacman -Rsn $(pacman -Qdtq)
#	    sudo reboot
            ;;
	"List Installed Kernels")
            echo "you chose choice $REPLY which is $opt"
	    find /boot/vmli*
	    ./kernelswitch.sh
	    ;;
	"Edit default GRUB file")
            echo "you chose choice $REPLY which is $opt"
            sudo nano /etc/default/grub
            sudo grub-mkconfig -o /boot/grub/grub.cfg
	    sudo reboot
	    ;;	
        "Quit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done

Online

#2 2023-12-23 15:07:12

MAYBL8
Member
Registered: 2022-01-14
Posts: 254

Re: Kernel Load script and some utilities

I think I posted this in the wrong place.
Shouldn't it be in Programing and scripting?
Thanks

Online

#3 2023-12-23 19:53:40

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,269
Website

Re: Kernel Load script and some utilities

MAYBL8 wrote:

Shouldn't it be in Programing and scripting?

That's for "programming issues and discussion" so I think "Community Contributions" is better suited for this.


Para todos todo, para nosotros nada

Offline

Board footer

Powered by FluxBB