purge-old-kernels deprecated

Bo Berglund bo.berglund at gmail.com
Sat Jan 7 09:51:30 UTC 2023


On Thu, 05 Jan 2023 19:54:21 +0100, Ralf Mardorf via ubuntu-users
<ubuntu-users at lists.ubuntu.com> wrote:

>On Fri, 2023-01-06 at 02:09 +0800, Bret Busby wrote:
>> apt update
>> apt full upgrade -y
>> apt autoremove
>> apt autoclean
>
>My update script runs
>
>            sudo apt update $quiet$color && \
>            sudo apt-file update && \
>            sudo auto-apt updatedb && \
>            sudo auto-apt update-local && \
>            sudo apt full-upgrade $keepp$color && \
>            sudo apt autoremove $color;;
>        esac
>        printf "\nsudo mv -i /var/cache/apt/archives/* /root/tmp_trash/\n"
>        sudo mv -i /var/cache/apt/archives/* /root/tmp_trash/
>
>that is more or less the same as you run, with one big exception. The
>content of the variables $keepp, $color is unimportant, since the
>content is at least not "-y".
>

I don't understand the above commands fully, for example the esac and color
parts. Should esac not be preceded by case somewhere?

But want to put the process into a script so it can be executed simply by
calling the script with sudo.

After seeing the Bret Busby post I started writing this, will that work or do I
have to handle other stuff as well:

----
#!/bin/bash
# This script will do a full system update-upgrade-clean process
# It must be called using sudo with argument Y

if [ "$1" != "Y" ]; then
  echo "Error! Call syntax: sudo $0 Y"
  echo "Try again!"
  exit -1
fi

apt update
if [ $? != "0" ]; then
  echo "Unable to run apt update command! Exiting..."
  exit 1
fi

apt full-upgrade -y
if [ $? != "0" ]; then
  echo "Unable to run apt full-upgrade -y command! Exiting..."
  exit 2
fi

apt autoremove
if [ $? != "0" ]; then
  echo "Unable to run apt autoremove command! Exiting..."
  exit 3
fi

apt autoclean
if [ $? != "0" ]; then
  echo "Unable to run apt autoclean command! Exiting..."
  exit 4
fi

echo "System updated/upgraded successfully"
exit 0
----

Grateful for comments!


-- 
Bo Berglund
Developer in Sweden




More information about the ubuntu-users mailing list