Usefull Scripts

  • I would like to (hopefully with the team's permission) open a thread where friendly people can share helpful scripts that are not directly related to OMV, but that make life easier—for example, scripts that can be used with the script plugin.

    Personally, I find it rather complicated to determine when exactly something was installed in Debian. While there is plenty of information available, evaluating it is complex. Here, therefore, is a Bash script that accomplishes this task.


    It show tings like this:


    Start-Date: 2025-06-30 15:10:41

    Commandline: apt-get --yes --allow-downgrades --allow-change-held-packages --fix-broken --fix-missing --auto-remove --allow-unauthenticated --show-upgraded --option DPkg::Options::=--force-confold dist-upgrade

    Upgrade: openmediavault-scripts:amd64 (7.3.1, 7.3.2)

    End-Date: 2025-06-30 15:11:27



    Start-Date: 2025-06-30 22:58:15

    Commandline: apt-get --yes --allow-downgrades --allow-change-held-packages --fix-broken --fix-missing --auto-remove --allow-unauthenticated --show-upgraded --option DPkg::Options::=--force-confold dist-upgrade

    Upgrade: sudo:amd64 (1.9.13p3-1+deb12u1, 1.9.13p3-1+deb12u2)

    End-Date: 2025-06-30 22:58:49


    or

    Start-Date: 2025-06-27 03:03:14

    Commandline: apt install openmediavault-scripts

    Install: python3-isort:amd64 (5.6.4-1, automatic), python3-wrapt:amd64 (1.14.1-2+b2, automatic), shellcheck:amd64 (0.9.0-1, automatic), pylint:amd64 (2.16.2-2, automatic), python3-mccabe:amd64 (0.7.0-1, automatic), python3-platformdirs:amd64 (2.6.0-1, automatic), python3-tomlkit:amd64 (0.11.7-1, automatic), openmediavault-scripts:amd64 (7.3), python3-lazy-object-proxy:amd64 (1.9.0-1+b1, automatic), python3-mypy-extensions:amd64 (0.4.3-4, automatic), python3-logilab-common:amd64 (1.9.8-1, automatic), python3-astroid:amd64 (2.14.2-1, automatic), python3-toml:amd64 (0.10.2-1, automatic), python3-dill:amd64 (0.3.6-1, automatic)

    Error: Sub-process /usr/bin/dpkg returned an error code (1)

    End-Date: 2025-06-27 03:04:28

    NAS 7.7.10-1 | Atom(TM) CPU D2550 @ 1.86GHz | Ram/Disk: 4GB/5,5TB + 8TB | Linux 6.1.0-32-amd64 | Raid5 + btfrs + Bcache + k3s
    3x k3s-worker 7.7.10-1 | Celeron(R) J4105 CPU @ 1.50GHz | Ram/Disk: 8/256 GB | Linux 6.12.32+bpo-amd64 |

    Edited once, last by Rd65 ().

  • Sometimes it is necessary to quickly compare the list of installed packages between two hosts in order to identify any differences. Provided you have access via SSH key, you can use the following script from a third machine (or from one of the hosts itself) to compare two systems with each other.


    an output can show:


    bash compare-pkgs.sh slave1 slave2

    ==> Pakete von slave1 werden geholt...

    Pakete insgesamt auf slave1: 595

    ==> Pakete von slave2 werden geholt...

    Pakete insgesamt auf slave2: 584

    Pakete, die NUR auf slave1 installiert sind:

    inetutils-telnet

    libblas3

    liblinear4

    liblua5.3-0

    libpcap0.8

    libpcre3

    libprotobuf-c1

    libunwind8

    linux-image-6.1.0-28-amd64

    lua-lpeg

    net-tools

    Pakete, die NUR auf slave2 installiert sind:



    this help to decide which packets to install on slave2 or remove on slave1 to be equal.

    NAS 7.7.10-1 | Atom(TM) CPU D2550 @ 1.86GHz | Ram/Disk: 4GB/5,5TB + 8TB | Linux 6.1.0-32-amd64 | Raid5 + btfrs + Bcache + k3s
    3x k3s-worker 7.7.10-1 | Celeron(R) J4105 CPU @ 1.50GHz | Ram/Disk: 8/256 GB | Linux 6.12.32+bpo-amd64 |

  • Sometimes you want to quickly identify configuration differences between two hosts.

    These could be different settings in configuration files, files that are present on one host but missing on the other, or any number of other differences. The following script helps you detect differences in files and directories between two hosts. Of course, the more files it has to process, the longer it will take.


    this will show things like:

    bash verg.sh '/etc/hosts' slave1 root slave2 root

    [INFO] Testing SSH connection to root@slave1...

    [INFO] SSH connection to root@slave1 successful.

    [INFO] Testing SSH connection to root@slave2...

    [INFO] SSH connection to root@slave2 successful.

    [DIFFERENCE] /etc/hosts

    ============== Difference: /etc/hosts ==============

    --- /tmp/tmp.gj8S18rtQp 2025-07-04 12:50:43.569949236 +0200

    +++ /tmp/tmp.0hZBYAtcp4 2025-07-04 12:50:46.013860959 +0200

    @@ -1,10 +1,10 @@

    127.0.0.1 localhost.localdomain localhost

    192.168.178.11 slave1 slave1

    -192.168.178.11 slave1 slave1

    +192.168.178.12 slave2 slave2

    192.168.178.12 slave2 slave2

    192.168.178.13 slave3 slave3

    192.168.178.3 omv omv

    -::1 localhost ip6-localhost ip6-loopback slave1 slave1

    +::1 localhost ip6-localhost ip6-loopback slave2 slave2

    fe00::0 ip6-localnet

    ff00::0 ip6-mcastprefix

    ff02::1 ip6-allnodes

    =======================================================



    Things like /etc/apt/ work too.

    bash verg.sh '/etc/apt/' slave1 root slave2 root

    [INFO] Testing SSH connection to root@slave1...

    [INFO] SSH connection to root@slave1 successful.

    [INFO] Testing SSH connection to root@slave2...

    [INFO] SSH connection to root@slave2 successful.

    [INFO] Directory mode: Searching '/etc/apt/' recursively on slave1...

    [DIFFERENCE] /etc/apt/sources.list

    ============== Difference: /etc/apt/sources.list ==============

    --- /tmp/tmp.pw1we59d5e 2025-07-04 11:59:35.964741770 +0200

    +++ /tmp/tmp.sJpHnF6GIn 2025-07-04 11:59:38.400653861 +0200

    @@ -1,4 +1,3 @@

    -deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware

    deb http://debian.charite.de/debian/ bookworm main contrib non-free non-free-firmware

    deb http://debian.charite.de/debian/ bookworm-updates main contrib non-free non-free-firmware

    deb-src http://debian.charite.de/debian/ bookworm main contrib non-free non-free-firmware

    =======================================================

    [EQUAL] /etc/apt/update-post-invoke-success.d/README

    [EQUAL] /etc/apt/pre-invoke.d/README

    [EQUAL] /etc/apt/update-pre-invoke.d/README

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-trixie-stable.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bookworm-security-automatic.asc

    grep: /etc/apt/trusted.gpg.d/openmediavault-archive-keyring.gpg: binary file matches

    grep: /etc/apt/trusted.gpg.d/openmediavault-archive-keyring.gpg: binary file matches

    [EQUAL] /etc/apt/trusted.gpg.d/openmediavault-archive-keyring.gpg

    grep: /etc/apt/trusted.gpg.d/openmediavault-keyring.gpg: binary file matches

    grep: /etc/apt/trusted.gpg.d/openmediavault-keyring.gpg: binary file matches

    [EQUAL] /etc/apt/trusted.gpg.d/openmediavault-keyring.gpg

    grep: /etc/apt/trusted.gpg.d/openmediavault.key.chroot.gpg: binary file matches

    grep: /etc/apt/trusted.gpg.d/openmediavault.key.chroot.gpg: binary file matches

    [EQUAL] /etc/apt/trusted.gpg.d/openmediavault.key.chroot.gpg

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-trixie-automatic.asc

    [EQUAL] /etc/apt/trusted.gpg.d/openmediavault.key.binary.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bookworm-automatic.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bullseye-automatic.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bullseye-stable.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bookworm-stable.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-bullseye-security-automatic.asc

    [EQUAL] /etc/apt/trusted.gpg.d/debian-archive-trixie-security-automatic.asc

    [EQUAL] /etc/apt/post-invoke.d/20fix-start-stop-daemon

    [EQUAL] /etc/apt/post-invoke.d/README

    [EQUAL] /etc/apt/listchanges.conf.d/95openmediavault.conf

    [EQUAL] /etc/apt/listchanges.conf.d/98openmediavault-mail.conf

    [EQUAL] /etc/apt/sources.list~

    [EQUAL] /etc/apt/sources.list.d/openmediavault-kernel-backports.list

    [EQUAL] /etc/apt/sources.list.d/openmediavault.list

    [EQUAL] /etc/apt/sources.list.d/openmediavault-os-security.list

    [EQUAL] /etc/apt/sources.list.d/omvextras.list

    [EQUAL] /etc/apt/sources.list.d/openmediavault-local.list

    [EQUAL] /etc/apt/preferences.d/proxmox.pref

    [EQUAL] /etc/apt/preferences.d/openmediavault-local.pref

    [EQUAL] /etc/apt/preferences.d/omvextras.pref

    [EQUAL] /etc/apt/preferences.d/openmediavault-kernel-backports.pref

    [EQUAL] /etc/apt/listchanges.conf

    [EQUAL] /etc/apt/apt.conf.d/01autoremove

    [EQUAL] /etc/apt/apt.conf.d/00trustcdrom

    [EQUAL] /etc/apt/apt.conf.d/20listchanges

    [EQUAL] /etc/apt/apt.conf.d/20auto-upgrades

    [EQUAL] /etc/apt/apt.conf.d/70debconf

    [EQUAL] /etc/apt/apt.conf.d/00CDMountPoint

    [EQUAL] /etc/apt/apt.conf.d/99openmediavault-apt-hooks

    [EQUAL] /etc/apt/apt.conf.d/98openmediavault-periodic-custom

    [EQUAL] /etc/apt/apt.conf.d/99openmediavault-localrepository

    [EQUAL] /etc/apt/apt.conf.d/95openmediavault-periodic

    [EQUAL] /etc/apt/apt.conf.d/99openmediavault-norecommends

    [EQUAL] /etc/apt/apt.conf.d/95openmediavault-unattended-upgrades

    [EQUAL] /etc/apt/apt.conf.d/99openmediavault-mkaptidx

    [EQUAL] /etc/apt/apt.conf.d/98openmediavault-unattended-upgrade-mail

    [EQUAL] /etc/apt/apt.conf.d/99dpkgnotify

    [EQUAL] /etc/apt/apt.conf.d/00recommends

    [EQUAL] /etc/apt/apt.conf.d/99openmediavault-nosuggests

    [EQUAL] /etc/apt/apt.conf.d/95openmediavault-unattended-upgrade

    [EQUAL] /etc/apt/update-post-invoke.d/README

    NAS 7.7.10-1 | Atom(TM) CPU D2550 @ 1.86GHz | Ram/Disk: 4GB/5,5TB + 8TB | Linux 6.1.0-32-amd64 | Raid5 + btfrs + Bcache + k3s
    3x k3s-worker 7.7.10-1 | Celeron(R) J4105 CPU @ 1.50GHz | Ram/Disk: 8/256 GB | Linux 6.12.32+bpo-amd64 |

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!