LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Bodhi
User Name
Password
Bodhi This forum is for the discussion of Bodhi Linux.

Notices


Reply
  Search this Thread
Old 09-04-2019, 07:21 AM   #1
madmax25
Member
 
Registered: Aug 2018
Posts: 348

Rep: Reputation: Disabled
Bodhi - Kernel update via bash - My suggestion. Your opinion?


Because I consider it quite annoying to type in the name of each of the 5 kernel packages, when installing (or removing) a new kernel, I created a bash script to make it easier.
What do you think about it?

Code:
 Install kernel:
*****************

read -p "Please enter kernel number: `echo '\n> '`" a
sleep 1
echo

sudo apt install linux-headers-"${a}" linux-headers-"${a}"-generic linux-image-"${a}"-generic linux-modules-"${a}"-generic linux-modules-extra-"${a}"-generic
sleep 2
echo

read -p "Please close with the Enter-key ... " Enter
and here the script for removing the kernel:

Code:
 Remove kernel:
****************

read -p "Please enter kernel number: `echo '\n> '`" a
sleep 1
echo

sudo apt purge linux-headers-"${a}" linux-headers-"${a}"-generic linux-image-"${a}"-generic linux-modules-"${a}"-generic linux-modules-extra-"${a}"-generic
sleep 2
echo

read -p "Please close with the Enter-key ... " Enter
I did this, because ukuu failed to install a kernel lately.

Last edited by madmax25; 09-04-2019 at 07:36 AM.
 
Old 09-04-2019, 07:45 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
what happens if I enter "K" ?

what happens when user tries to uninstall a kernel that does not exist?


some things for you to play with

Code:
apt list linux-{image,header}*
apt list --installed linux-{image,header}*
maybe you could show the user some options based on what you find.
 
Old 09-04-2019, 08:43 AM   #3
madmax25
Member
 
Registered: Aug 2018
Posts: 348

Original Poster
Rep: Reputation: Disabled
These two scripts are not supposed to replace ukuu.
I assumed, you know already (for example from the grub menu or from Synaptic) what kernels have been installed before.

To prevent a non-existing kernel from being uninstalled, you might look it up in Synaptic, by entering only the number of the one you intent to uninstall.
If it is there, go ahead using the 2nd script, if not, you're done already.

If you enter a "K", nothing happens until you hit the Enter-key.

These two scripts are just supposed to be helpful for installing a kernel, just to see if it fixes some issues, you are currently facing.
In case the new kernel doesn't fix anything, You usually know which one you just installed and then you can use the 2nd script to uninstall it again.

If you think, you should add some features, feel free to go ahead, please.
Any improvement is welcome, of course.

I guess, the two commands should also list the modules, so it would be:
Code:
apt list linux-{image,headers,modules}*
apt list --installed linux-{image,headers,modules}*
The problem as I see it, is that this list can get quite confusing, because it doesn't list the packages sorted by version numbers.
 
Old 09-04-2019, 09:01 AM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
if I enter "k" and hit enter
your list of commands wastes some time and does nothing
same with the uninstall


What you have is a great project to teach yourself how to write a shell script.

What you don't have ( yet ) is a shell script.

this is not how I would *actually* do it, but
as example
Code:
< <(apt list linux-{image,headers,modules}*) awk '{print $2," ",$3}'|sort -u
 
Old 09-04-2019, 01:20 PM   #5
madmax25
Member
 
Registered: Aug 2018
Posts: 348

Original Poster
Rep: Reputation: Disabled
I don't know what you are doing, but her it does exactly what it is supposed to.
 
Old 09-23-2019, 06:25 PM   #6
madmax25
Member
 
Registered: Aug 2018
Posts: 348

Original Poster
Rep: Reputation: Disabled
Oops sorry, I forgot a $ key after echo !

In the lines with the read command I wrote...

read -p "Please enter kernel number: `echo '\n> '`" a

but instead, it is supposed to be...

read -p "Please enter kernel number: `echo $'\n> '`" a
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ubuntu 18.04-Based Bodhi Linux 5.0 Enters Beta with Bodhi Builder Improvements LXer Syndicated Linux News 0 05-30-2018 11:12 AM
[SOLVED] [Suggestion] Linux Kernel 3.18 it's Longterm now, suggestion for Slackware Current sardinha Slackware 27 04-03-2015 05:17 PM
LXer: Bodhi Linux 2.4.0 Released, One Year Left Until Bodhi 3.0.0 LXer Syndicated Linux News 0 09-14-2013 05:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Bodhi

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration