mintupdate-on-wakeup: an easy way of doing unattended upgrades

Enkitux
  3 years ago
  0

One thing, Linux Mint is not very famous for (but getting better) are automatic updates! :( You know that kind of simple thing every Windows user never needs to care about!? By default, Windows just installs important updates! That's it!

Using Mint, you can enable it by cron once a day but you do not really recognize it.

So I developed a tiny little script that will do it a bit different!
E.g. you get some notifications that it is checking, updating, ...

And because I think it could be helpful for more people here a small tutorial what it does and how to install it:

 

mintupdate-on-wakeup v2.0

It is just a kind of wrapper around mintupdate-cli/tool that does the real stuff.

Nowerdays a normal user has a notebook, laptop, ultrabook or similar. You just use it. Take it, open it, close it, leave it, ... It will suspend and resume a couple of times a day.

And this is where my script hooks in. On every wakeup, it will be called. And with a quite intelligent neat algorythm *haha* it will check for new updates maybe 1-3 times a day. (Even if there are some hundred resumes.) Together with the ability to send some destop notifications.


What does it do?

It will be hooked into /lib/systemd/system-sleep. Thus it will be called on every suspend/resume.

Then it checks its last run and it that was too early ago, nothing will happen. Otherwise minteupdate-cli/tool will be called to check for and install the updates (depending on your needs).

Sounds simple!? Yes! Using my script it (hopefully) is that simple.

 

How to install?

  • Download the script from the link below
  • Unzip and place it in $HOME/bin (or any folder you like)
  • Edit script to adjust some defaults (see top of script)
  • > chown 755  $HOME/bin/mintupdate-on-wakeup
  • > sudo ln -s $HOME/bin/mintupdate-on-wakeup /lib/systemd/system-sleep/
  • Enjoy! :D
  • ... and take a look at /var/log/mintupdate-on-wakeup.log for details.

 

Some challanges I had...

Well... Since the introduction of mintupdate-cli/tool it is quite easy to start updating from a script.'

So I thought I just needed an automatism thar fits my needs. But damned, it was quite tricky to resolve some issues being called from systemd (root), launching a backround process and sending notifications from root to the desktop user...

Placing a script in /lib/systemd/system-sleep is quite easy.

  • But systemd will kill it, when it needs too long.
  • But pushing it in the backround was not so easy as I thought!
    (nohup/disown did not work, dunno why..)

Because I want to know when it is working, throwing some notifications would be nice, I thought.
By using notify-send, this is quite easy. Just do it!

  • But not, when you try to do that from a poor root shell!
  • But not, if you want to send the notification to a different user!
  • But not, if you need the correct DBUS_SESSION_BUS_ADDRESS!

So I needed a while to figure all that out. But I could solve all issues, i think. (I am not sure about DBUS, if this is waterproof. But anyway, the only thing that not happens, if there is a problem are notiifications. ;) )

 

So have fun and hopefully no pain with it.

 

I am open for any kind of feedback, credits, feature-requests, donations, praise, ... :D

 

Cheers,
Enkidu

 

 


Prerequisite:

> sudo apt-get install ...
  1. at
  2. libnotify-bin (if you want to receive desktop notifications)
     

Downlod:

 

Comments
Enkitux 3 years ago

Damned... Needed 2 years to switch from Mint 18 to 20.1... :D
But finally it is done and my script now works with LM >18 too! ;)


ghost123uk 5 years ago

Thanks for your work on this.
I eagerly await an LM19 version


Enkitux 5 years ago

@ZeckeSZ, as I already wrote in my text above, I have developed it on LM18 and there is no mintupdate-cli, only mintupdate-tool.
I will port it asap.


ZeckeSZ 5 years ago

Calling mintupdate-tool in terminal shows this hint:
"mintupdate-tool is depecrated, please use mintupdate-cli instead"


Enkitux 5 years ago

@remoulder, this is just a bash script, not a binary, dude.
You can take a look into it and will see, it does not do anything bad. (As long as you trust mintupdate-tool :D)

Very /helpful/ comment. Tnx. :(

It would have been more useful if you'd take a look into it, review it and give some real helpful comment on it.


remoulder 5 years ago


WARNING: Do not install software from unknown sources