[script] AMU - Automatic Manjaro Updater

Hello guys,

I created a script that automatically updates your Manjaro system on every shutdown, but not at reboot, This ensures that you can continue to use your PC without having to wait for your system to finish updating! looking at you Windows

The GitHub page with installation instructions & additional information can be found here:

UPDATING YOUR SYSTEM AUTOMATICALLY MIGHT RESULT IN A BRICKED AND UNUSABLE SYSTEM! I’M NOT RESPONSIBLE SHOULD THIS HAPPEN, YOU HAVE BEEN WARNED!

This being said, the script runs on two different systems since about two months without any issues. If your software is not too exquisite (like many AUR packages) and you use the STABLE branch of Manjaro, you should be fine.


THIS SCRIPT IS ONLY(!) THOUGHT FOR MANJARO-BASED INSTALLATIONS AND NOTHING ELSE! IT WILL NOT WORK AS INTENDED OR MAKE THE SYSTEM UNUSABLE ON OTHER SYSTEMS! USE AT YOUR OWN RISK!

This script will install my custom script to update your system when it’s being shutdown. It is tested on Manjaro 21.1.6, but should work on future versions as well.

The script requires root privileges to copy the files to the corresponding locations.

This script also includes a service that updates your flatpak and snap packages at startup.

In order for the script to work, you need to install Plymouth using the installation guide here: Plymouth - Manjaro A step-by-step explanation on what to do is also given on the github page!

Pamac (the default package manager) is used to update the system!

Features

  • automatically search for updates at shutdown
  • update at shutdown only, not at reboots
  • use systemd to stay compatible over system updates
  • integration with all Manjaro flavors
  • graphical integration with progress bars
  • updates your flatpak and snap packages at startup
  • independant of the desktop environment
  • logs are saved at /var/log/manjaro-automatic-update/
  • only apply updates when battery is charged to 50% and connected to power (notebook only)

Known Issues

  • requires Plymouth
  • Automatically updating the system is not recommended and can potentially break your system! Do not expect help in the official forum should this script break your system!

Pictures

Installing Updates

Contribution

I’m open and welcome contributions to make this script better and/or available to more distributions. Currently, the script is quite hacky as it is not using the offline-update service, but a custom solution. If you know a better approach, feel free to open a pull request!

Should you encounter any issue, please open an issue. Use at your own risk!

4 Likes

Would it be possible to trigger it manually as Update & Reboot, like in Fedora?

2 Likes

I don’t really know if I get your question right.
You really just need to hit “shutdown” in your Desktop Environment and it will start updating - so there is no need for an extra Update & Reboot button. :slight_smile:

It will not work when you hit “reboot” though. It would be very easy however to make it update your system at reboots as well - just remember that it will then update your system on EVERY reboot.

I hope this answers your question! :slight_smile:

1 Like

The idea was, rather than making it automatic on every shutdown, to have it triggered manually, so it “closes the session”, updates and reboots. Akin to Windows’ (forced) Update & Restart and, AFAIK, to how Fedora handles system updates (on-demand).

Without being too negative … why does it rely on plymouth?

Ah, I see what you mean.

This would be quite easy to do, depending on your knowledge of scripting and systemd.
Could you get some experience there already?
Alternatively I can guide you through step by step, it’s really not that difficult. :slight_smile:

But there won’t be a nice button in some menu or something, just a script file on your desktop you click on to execute it.

Technically it doesn’t: The script waits for Plymouthd to start, to be able to switch to the Updater screen you see above.
If Plymouth doesn’t start, the script will wait endlessly - and the PC won’t shutdown.

This is pretty easily solvable though, by adding a check if Plymouth is installed.
I didn’t do it though as I personally use it and it was just intended for that, but thought others might find it useful as well.

Do you think I should edit it so it still updates without Plymouth installed? (but then also without a screen indicating the progress)

Plymouth is (rightly) not commonly installed … and its a bit of an odd requirement.
(though I guess what you are going for is the animation and/or on-screen-response)

You’re right, it is, but I used Fedora and Kubuntu before and they both use Plymouth and this updater screen, so I found it convenient to use it here as well.

Additionally, I don’t think that the pre-installed bootscreen of Manjaro has such an Updater screen, right?
Or do you have another idea how to get a working indicator easily?

Alternatively, you can disable the installed service, so it doesn’t trigger on shutdown and doesn’t update your system.

If you want to update, you can then enable it with a script/single command and shutdown your PC, so it triggers.
This would be more “on-demand” than in the current state, but still not completely user-friendly as there would still be no extra button for it in a menu.

I don’t really understand what the added value of the AMU script is compared to the built-in update checker of Manjaro’s package manager Pamac (Add/Remove Software). The Pamac Updater can automatically check and notify you of any available system updates. If updates are pending, you can first do all your work in peace and then apply the updates before shutting down the computer. At least that’s how I do it with updates and I’ve done very well with it so far. :slight_smile:

@Tobi_Peter System services should be installed to /usr/lib/systemd/system/. When enabled, they will be symlinked to /etc/systemd/system/.

2 Likes

The benifit is that one doesn’t have to wait until the updates are applied.

I wanted multiple times to update my system, but I was really tired and didn’t want to wait until they are installed, but didn’t want to install them earlier either, as the update might require a restart.
This is why I created this script, so I don’t have to worry about that anymore. :slight_smile:

If you’re happy with your workflow, that’s great as well! You don’t have to use it. :wink:

1 Like

Oh, thank you very much, didn’t know that!
I’ll correct it in a few days.
I’m not really experienced with systemd services, so any advice is helpful!
Should you find anything else that’s not solved optimally, feel free to comment here or open an issue on Github! :slight_smile:

Posting this as a bit of healthy competition (feel free to take ideas from it)

xs-update-manjaro

Differences:
-Aims to support any distro based on Arch Linux, but primarily tested on Manjaro
-Highly configurable
-Status updates via notifications (no progress bar)
-Updates signature keys, mirrorlist, repo packages, AUR packages, and flatpak packages
-Uses pacman and flatpak directly (does not currently use pamac)
-Supports updating itself
-Individual update tasks can be assigned a “frequency” at which to perform (every X days)
-Includes automatic fixes for common issues, including automatic rebuild of AUR packages when needed
-Provided service can be enabled to run at startup, run manually, or otherwise scheduled
-Computer can still be used while it is updating - optional automatic reboot or shutdown after critical package updates

I’ll likely create a dedicated post for this after I’ve finished implementing automatic kernel management

This really looks great, not gonna lie! :slight_smile:

It doesn’t seem to fit my use case though (updating when I don’t need the machine anymore, aka. at shutdown), at least if I didn’t overlook anything.
Otherwise I’d probably delete my script. :stuck_out_tongue:

The automatic kernel managment is tempting, maybe it’s even possible to more or less integrate the main idea of my script (to update the system at shutdown) into yours?
But that’s up to you of course. :slight_smile:

If you enter sudo pacman -Syu && shutdown, would it not simply update your system, then shut down your machine? Without you needing to wait for it to finish.

Or I misunderstood the aim of your script.

1 Like

Sure, xs-update-manjaro supports shutting down after running it. You’d set the following in /etc/xs/auto-update.conf:

Have script initiate shutdown:

reboot_action_str=poweroff#changes power action to shutdown instead of reboot
reboot_1enable_num=2#tell script to always perform the power action, regardless of what updates were installed

Shutdown performed by systemd after script execution:

reboot_1enable_num=-1#tell script to never perform the power action,  it will always exit normally

Outside of that, the script can be triggered by whatever you want.

You can modify your shutdown service to execute my update script as follows:


[Unit]
Description=Update on Shutdown
RequiresMountsFor=/ /home /boot
DefaultDependencies=no
Requires=network-online.target multi-user.target local-fs-pre.target local-fs.target NetworkManager.service
Upholds=network-online.target multi-user.target local-fs-pre.target local-fs.target NetworkManager.service
After=multi-user.target
Before=systemd-poweroff.service shutdown.target umount.target final.target systemd-halt.service

[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/usr/share/xs/auto-update nofork
TimeoutSec=infinity
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

(launching my script with nofork as a parameter prevents it from forking to the background, so the service should detect it as running for the duration of the update)

The only downside is that if my script updates itself, using this method it won’t update the rest of the system until the next time it is run. This is because the script re-launches itself after updating, and the service won’t detect that. Setting Type=forking in the unit might work in that scenario.

I like the progress screen for when you have it shutting down. I could see my script supporting that via a launch parameter in the future. You’re welcome to create an issue requesting that. Pull requests are also welcome - just know that I probably won’t have time to vet it until after I’ve finished implementing the kernel management.

1 Like