What It Does
On apt, the script refreshes package lists even in a dry run so the plan uses current metadata. On dnf it asks the package manager which updates are pending. Security scope uses apt's security-source matches or dnf's security filter. All uses all updates in scope. EXCLUDE_PACKAGES filters candidate updates; the package manager applies holds and resolves dependencies.
Updating a package can install dependencies. The script has no separate package-removal step. On apt it sets needrestart to list mode; this does not control every action a package installer can take. After installation it checks again. If the same number or more updates remain, it reports an error. A smaller remaining count produces a warning.
It can schedule a needed reboot when REBOOT_IF_REQUIRED is true, the shutdown command is present, and no console or desktop user is detected by who. SSH sessions do not count. It schedules the reboot in one minute, and shutdown -c cancels it. In every other case the answer says reboot required when the machine needs one.
The package manager's own output goes to /var/log/mspoutpost/install-linux-updates.pm.log (the last run only), and each planned update is written to the change log after the install command succeeds. SUSE and Arch are not supported.
Before You Run It
- Run with DRY_RUN=true first. It lists updates without installing them. On apt it still refreshes the package list, and it resets the package-manager log.
- Take a snapshot or backup of a server that matters before you patch it.
- Plan the reboot. A reboot-required answer means a restart is still owed, and the services keep running old code until then.
- Leave REBOOT_IF_REQUIRED false on servers where a restart needs a maintenance window.
- It was run on Ubuntu 24.04 with apt. The dnf path (Debian 12, RHEL, Rocky and Alma 9) is written for but not yet run, so try it on one server first.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: Low. Set DRY_RUN=true to list every change without making any.
- What it changes: Installs package updates (and any new packages they need); optionally schedules a reboot.
- Restart: It restarts the machine itself: that is its job, or an input you set turns it on. The answer says when.
- Typical run: 1 to 30 minutes.
- Example answer: "Installed 7 security updates; reboot required"
- Tested before listing on Ubuntu 24.04 (Arm64 VM) with bash, run as root, against its own test cases.
Inputs
Pass an input as an argument (--input-name value), as an environment variable named as listed, which is how most RMMs pass script variables, or change its default in the DEFAULT_ lines near the top of the script. An argument wins over an environment variable, which wins over the default.
- UPDATE_SCOPE: Security (default) or All.
- EXCLUDE_PACKAGES: Package names never to update, comma-separated. Default none.
- REBOOT_IF_REQUIRED: true to reboot (in one minute) when needed and nobody is signed in. Default false.
Every script also takes DRY_RUN, OUTPUT_FORMAT (Text, Answer, Json or Csv), EXPORT_PATH and RESULT_FIELD, which writes the answer to an RMM custom field, unless the list above words one differently.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.