Here is a little bash script i wrote to help with kernel management.
#1
Feel free to use it if you think it's useful.

Code:
#!/bin/bash

if [[ "$EUID" -ne 0 ]]; then
  echo "This script must be run as root" 1>&2
  exit 1
fi

function logo()
{     echo " _____             _____         "
      echo "|  |  |___ ___ ___|     |___ ___ "
      echo "|    -| -_|  _|   | | | | .'|   |"
      echo "|__|__|___|_| |_|_|_|_|_|__,|_|_|"
      printf "\nKernMan - Kernel Management Assistant.\n"
}  

logo

function usage()
{ printf "\nKernMan is a script written for the purpose of simplifying Kernel Management.

Select the option 'List' to display all installed kernels select the option 'Purge' to display
all kernels that can be removed and subsequently do so\n\n"
}



PS3='Please enter your choice: '
options=("Usage" "List" "Purge" "Quit")
select opt in "${options[@]}"
do
   case $opt in
       "Usage")
           usage
           ;;
       "List")
           dpkg -l linux-image-\* | grep ^ii
           ;;
       "Purge")
           kernelver=$(uname -r | sed -r 's/-[a-z]+//')
           dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver
           
           printf "\nThese items will be deleted.\n"
           read -p 'Continue? Y/n ' choice
           
           if [[ $choice == "y" ]]; then
               sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
           else
               echo "Aborted"
               break
               exit 1
           fi
           ;;
       "Quit")
           break
           ;;
       *) echo invalid option;;
   esac
done
Reply
#2
Was this something you wrote? Looks really clean, good job!
Reply
#3
(12-25-2016, 07:54 PM)NO-OP Wrote: Was this something you wrote?  Looks really clean, good job!

Yes it was, although i had to look up some commands it's my script.

I put it up on github as well you can find it by clicking here.
Reply
#4
This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.
Reply
#5
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Well, he said you are free to use it if you want so I suppose you can use it for your company too Smile
"Feel free to use it if you think it's useful."
Reply
#6
(12-30-2016, 08:58 PM)enmafia2 Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Well, he said you are free to use it if you want so I suppose you can use it for your company too Smile
"Feel free to use it if you think it's useful."

Yeah if you want to use something professionally you're going to want a license. It would be super easy to sue someone over something like that and he would lose his job over using a script that didn't have a proper license.
Reply
#7
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Thank you for asking, you can freely distribute, modify and use this code for any purpose you should desire. If someone asks where you got it from though i would appreciate a shoutout to my github Smile  That's all i really would like in return.

(12-30-2016, 09:07 PM)NO-OP Wrote:
(12-30-2016, 08:58 PM)enmafia2 Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Well, he said you are free to use it if you want so I suppose you can use it for your company too Smile
"Feel free to use it if you think it's useful."

Yeah if you want to use something professionally you're going to want a license.  It would be super easy to sue someone over something like that and he would lose his job over using a script that didn't have a proper license.

It is now published under the GNU General Public License. See my github for details. But i am sure everyone here is familiar with it Tongue
Reply
#8
Spoiler(Show)
(12-30-2016, 10:52 PM)Vector Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Thank you for asking, you can freely distribute, modify and use this code for any purpose you should desire. If someone asks where you got it from though i would appreciate a shoutout to my github Smile  That's all i really would like in return.

(12-30-2016, 09:07 PM)NO-OP Wrote:
(12-30-2016, 08:58 PM)enmafia2 Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Well, he said you are free to use it if you want so I suppose you can use it for your company too Smile
"Feel free to use it if you think it's useful."

Yeah if you want to use something professionally you're going to want a license.  It would be super easy to sue someone over something like that and he would lose his job over using a script that didn't have a proper license.

It is now published under the GNU General Public License. See my github for details. But i am sure everyone here is familiar with it Tongue


I put the quotes into the spoiler.
Thank you very much Vector, this is compatible with the usage at work. Of course, I will attribute it if anyone asks. 

And NO-OP is correct. I would indeed need a license to use it.
Code is copyrighted material. Without a proper license, I cannot use it at work, as I would be violating copyright law.
This would indeed be very, very, very bad for my job if someone notices.
If they sue us, there's a chance I could also be sued -- it was me who committed the violation, and if I had committed the violation, there was no real agreement signed, so I could be opening myself up for some personal liability there. IANAL, but an abundance of caution is a good idea generally anyways.
Reply
#9
(12-31-2016, 12:01 PM)VenAAX Wrote:
Spoiler(Show)
(12-30-2016, 10:52 PM)Vector Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Thank you for asking, you can freely distribute, modify and use this code for any purpose you should desire. If someone asks where you got it from though i would appreciate a shoutout to my github Smile  That's all i really would like in return.

(12-30-2016, 09:07 PM)NO-OP Wrote:
(12-30-2016, 08:58 PM)enmafia2 Wrote:
(12-30-2016, 05:50 PM)VenAAX Wrote: This might actually be useful for me (at work).

Do you mind if I use this for business reasons? It will not be distributed with any products, only as a use within the company, limited to the VMs that I deploy and have a personal purview over.

I will only use it with permission, ofc.

I have to ask permission as it does not have a license attached to it.

Well, he said you are free to use it if you want so I suppose you can use it for your company too Smile
"Feel free to use it if you think it's useful."

Yeah if you want to use something professionally you're going to want a license.  It would be super easy to sue someone over something like that and he would lose his job over using a script that didn't have a proper license.

It is now published under the GNU General Public License. See my github for details. But i am sure everyone here is familiar with it Tongue


I put the quotes into the spoiler.
Thank you very much Vector, this is compatible with the usage at work. Of course, I will attribute it if anyone asks. 

And NO-OP is correct. I would indeed need a license to use it.
Code is copyrighted material. Without a proper license, I cannot use it at work, as I would be violating copyright law.
This would indeed be very, very, very bad for my job if someone notices.
If they sue us, there's a chance I could also be sued -- it was me who committed the violation, and if I had committed the violation, there was no real agreement signed, so I could be opening myself up for some personal liability there. IANAL, but an abundance of caution is a good idea generally anyways.

Happy to help out, may it save you lots of valuable time at work!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AES256 On the fly with Bash. Vector 1 3,240 03-16-2022, 06:46 AM
Last Post: Vector
   could someone help me fix this logic error QMark 2 2,807 02-23-2022, 07:34 PM
Last Post: QMark
  What’s the issue here ? FancyBear 4 22,413 01-13-2021, 06:50 PM
Last Post: Vector
  Having an issue writing a python script with vim FancyBear 4 22,491 01-03-2021, 11:27 PM
Last Post: FancyBear