#!/bin/bash
#
# block_checkpoint.sh - Perforce trigger to block "p4 admin checkpoint"
#
# Trigger table entry:
# block-checkpoint command pre-user-admin "/path/to/block_checkpoint.sh %user% %args%"
#
# This trigger fires before any "p4 admin" command. The script checks
# if the subcommand is "checkpoint" and blocks it.
USER="$1"
shift
ARGS="$*"
if echo "$ARGS" | grep -qi "checkpoint"; then
echo "Checkpoint blocked: User '$USER' attempted to run 'p4 admin checkpoint'. This command is not permitted."
exit 1
fi
# Allow all other "p4 admin" subcommands
exit 0