loginctl enable-linger "$(id -nu)"
if command -v podman; then
podman system info > /dev/null || podman system reset --force
- PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]')
- if [ "$PODMAN_MAJOR_VERSION" -lt 4 ]; then
+ if [ "$(podman version -f "{{ lt .Client.Version \"4\" }}")" = "true" ]; then
echo "Found a very old podman; removing"
command -v dnf && sudo dnf remove -y podman
command -v apt && sudo apt remove -y podman
fi
if command -v podman; then
- PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]')
- if [ "$PODMAN_MAJOR_VERSION" -ge 4 ]; then
+ if [ "$(podman version -f "{{ ge .Client.Version \"4\" }}")" = "true" ]; then
PODMAN_DIR="$HOME/.local/share/containers"
test -d "$PODMAN_DIR" && command -v restorecon && sudo restorecon -R -T0 -x "$PODMAN_DIR"
PODMAN_STORAGE_DIR="$PODMAN_DIR/storage"
if [ "$(podman unshare du -s --block-size=1G "$PODMAN_STORAGE_DIR" | awk '{print $1}')" -ge 50 ]; then
time podman image prune --filter=until="$((24*7))h" --all --force
time podman system prune --force
- test "$PODMAN_MAJOR_VERSION" -ge 5 && time podman system check --repair --quick
+ if [ "$(podman version -f "{{ ge .Client.Version \"5\" }}")" = "true" ]; then
+ time podman system check --repair --quick
+ fi
fi
fi
fi