#!/bin/sh set -eu src=/var/lib/systemd/pstore dst=/var/log/pstore mkdir -p "$dst" chmod 0750 "$dst" found=0 if [ -d "$src" ]; then for source_file in "$src"/*; do [ -f "$source_file" ] || continue found=1 base=$(basename "$source_file") digest=$(sha256sum "$source_file" | awk '{print substr($1, 1, 16)}') target="$dst/$digest-$base" if [ ! -e "$target" ]; then cp -a "$source_file" "$target" chmod 0640 "$target" 2>/dev/null || true fi done fi if [ "$found" -eq 1 ]; then logger -t control-pstore-collect "archived systemd pstore files in $dst" fi