#!/bin/bash
# Put Starchaser's faillock.conf (5 wrong passwords, then a 30-second wait) in place: starchaser-faillock-conf SOURCE DEST.
# Arch's pam package owns DEST, so this copies instead of shipping. It writes only when DEST is missing, is still
# Arch's all-comments file, or is already Starchaser's own; any setting a person put in it keeps it as it is.
set -euo pipefail
src=${1:?source} dst=${2:?destination}
if [ -f "$dst" ] && grep -qv '^[[:space:]]*\(#\|$\)' "$dst" && ! grep -qF '# Starchaser Linux' "$dst"; then
  echo "faillock.conf has your own settings: left as it is"
  exit 0
fi
cmp -s "$src" "$dst" 2>/dev/null || install -Dm644 -o "$(id -u)" -g "$(id -g)" "$src" "$dst"
