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.
#!/bin/bash
echo "APT-Installations-Timeline (aus history.log, alle archivierten Logs):"
echo
LOG_FILES=$(ls /var/log/apt/history.log* 2>/dev/null | sort -Vr)
for LOG in $LOG_FILES; do
if [[ "$LOG" == *.gz ]]; then
zcat "$LOG"
else
cat "$LOG"
fi
done | awk '
function trim(str) { sub(/^ +/, "", str); sub(/ +$/, "", str); return str }
BEGIN {block=""; show=0;}
/^Start-Date:/ {
if (block != "") {
print block "\n";
block = "";
}
block = $0 "\n";
show = 1;
next;
}
/^Commandline:/ {
block = block $0 "\n";
next;
}
/^Installierte Pakete:/ {
block = block "Installierte Pakete:\n";
while (getline line > 0) {
line = trim(line);
if (line ~ /^End-Date:/ || line ~ /^Start-Date:/ || line ~ /^Commandline:/) {
block = block "\n" line "\n";
if (line ~ /^End-Date:/) show=0;
else show=1;
break;
}
if (line ~ /^- /) {
pkg = line;
if (getline dep_line > 0) {
dep_line = trim(dep_line);
dep = "";
if (dep_line == "- automatic)") dep = " [Abhängigkeit]";
else {
# dep_line keine Abhängigkeit, wiederverwenden
ungetline = dep_line;
}
if (match(pkg, /^- ([^:]+:[^ ]+) \(([^)]+)\)/, m)) {
block = block sprintf(" - %s (%s)%s\n", m[1], m[2], dep);
} else {
block = block pkg "\n";
}
if (dep_line != "- automatic)" && dep_line ~ /^- /) {
pkg = dep_line;
dep_line = "";
# geht gleich nochmal in die Schleife
ungetline = "";
}
}
}
}
next;
}
/^End-Date:/ {
block = block $0 "\n";
print block "\n";
block = "";
show=0;
next;
}
{
if (show) block = block $0 "\n";
}
'
Display More
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