Page 1 of 1

System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 10:50 am
by manyroads
I am trying to create a robust, thorough & simple to run script that cleans my MX setup, removes "cruff", and updates then upgrades the entire setup.

To that end, here is what I have thus far:

Code: Select all

#!/bin/sh
# clean Debian system, update, upgrade the current desktop

sudo apt -y autoclean &&
sudo apt -y autoremove --purge &&
sudo apt -y dist-upgrade --auto-remove --purge
I welcome & appreciate comments, additions, and other useful assistance.

When completed, I'll map the script execution to a keybinding to magically launch and process this basic system maintenance. :crossfingers:

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 10:57 am
by oops
... Hello, et FI: I use automatically , config. every week:

Code: Select all

su-to-root -x -c mx-cleanup &
# and sometime, by hand sometimes

Code: Select all

su-to-root -x -c bleachbit  &

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 11:40 am
by manyroads
Thank you oops!

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 11:41 am
by Head_on_a_Stick
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y autoremove --purge &&
If the user has inadvertantly removed part of a metapackage then that command might very well uninstall the whole desktop. We get threads about this regularly over at fdn.
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y dist-upgrade --auto-remove --purge
That might cause major problems if the OP has mixed sources and AFAIUI MX isn't designed to dist-upgrade between releases so I'm not sure that should ever be used.
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y autoclean &&
Old .deb packages can be useful to downgrade to, although that is unlikely to ever be needed in a Debian stable based system.

And in general I don't think running any package manager with the -y option is a good idea but this may be a hang-up from my Arch days. Debian stable should be fine with that sort of thing but MX does play a little fast and loose with their repositories.

EDIT: and there's no point running dist-upgrade without updating the package database first ;)

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 1:08 pm
by manyroads
Head_on_a_Stick wrote: Tue Dec 31, 2019 11:41 am
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y autoremove --purge &&
If the user has inadvertantly removed part of a metapackage then that command might very well uninstall the whole desktop. We get threads about this regularly over at fdn.
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y dist-upgrade --auto-remove --purge
That might cause major problems if the OP has mixed sources and AFAIUI MX isn't designed to dist-upgrade between releases so I'm not sure that should ever be used.
manyroads wrote: Tue Dec 31, 2019 10:50 am

Code: Select all

sudo apt -y autoclean &&
Old .deb packages can be useful to downgrade to, although that is unlikely to ever be needed in a Debian stable based system.

And in general I don't think running any package manager with the -y option is a good idea but this may be a hang-up from my Arch days. Debian stable should be fine with that sort of thing but MX does play a little fast and loose with their repositories.

EDIT: and there's no point running dist-upgrade without updating the package database first ;)
So Matthew... are you trying to be nice to me and say, 'don't do this?' :number1:

If it is worth doing, what commands should I use? My normal cli stuff looks like:

Code: Select all

sudo apt autoclean  
sudo apt autoremove --purge
sudo apt update
sudo apt upgrade

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 2:13 pm
by Head_on_a_Stick
manyroads wrote: Tue Dec 31, 2019 1:08 pm are you trying to be nice to me and say, 'don't do this?'
Erm, maybe a little bit :bagoverhead:

What is it that you are actually trying to accomplish with this script?

For upgrades you could use the unattended-upgrades package and enable it for the MX repositories as well as the Debian security stuff, that would keep your system updated without you having to run any custom scripts. I've been using that method on the family laptop (currently still running Debian oldstable) and it's worked fine for several years now, I don't have to touch the machine at all.

In respect of autoclean, Debian stable based systems don't tend to accumulate large amounts of old .deb packages because the versions don't change. I suppose autoremove might be useful but only if you're in the habit of installing and then uninstalling stuff regularly.

Re: System Clean & Upgrade Script

Posted: Tue Dec 31, 2019 3:42 pm
by manyroads
Head_on_a_Stick wrote: Tue Dec 31, 2019 2:13 pm
manyroads wrote: Tue Dec 31, 2019 1:08 pm are you trying to be nice to me and say, 'don't do this?'
Erm, maybe a little bit :bagoverhead:

What is it that you are actually trying to accomplish with this script?

For upgrades you could use the unattended-upgrades package and enable it for the MX repositories as well as the Debian security stuff, that would keep your system updated without you having to run any custom scripts. I've been using that method on the family laptop (currently still running Debian oldstable) and it's worked fine for several years now, I don't have to touch the machine at all.

In respect of autoclean, Debian stable based systems don't tend to accumulate large amounts of old .deb packages because the versions don't change. I suppose autoremove might be useful but only if you're in the habit of installing and then uninstalling stuff regularly.
I think I'll just use my standard stuff and save a few keystrokes. I do actually install/ remove/ replace bunches of software. Maybe next year I'll be more stable. :rolleyes: