#!/bin/bash # SPDX-License-Identifier: LicenseRef-Starship-1.0 # Copyright (c) 2023-2026 Robert A. James # transcripts-tidy.sh DIR OWNER -- the demo's transcripts (#192): each handed to OWNER, mode 0600, so only OWNER # reads it (the session's user wrote it, and cannot list the directory); every one older than 7 days deleted. # Run as root by starshipos-demo-transcripts.timer every 5 minutes. Tests: demo/test_transcripts.py. set -euo pipefail dir=${1:?usage: transcripts-tidy.sh DIR OWNER} owner=${2:?usage: transcripts-tidy.sh DIR OWNER} [ -d "$dir" ] || { echo "transcripts-tidy: no $dir" >&2; exit 1; } find "$dir" -maxdepth 1 -type f -name '*.log' -mmin +10080 -delete # 7 days find "$dir" -maxdepth 1 -type f -name '*.log' ! -user "$owner" -exec chown "$owner:" {} + -exec chmod 0600 {} +