#! /usr/bin/env bash
set -eo pipefail

SCRIPT="$(basename "$0")"

usage() {
cat <<END
usage:
	$SCRIPT <file.crt>

	Install file.crt to /usr/local/share/ca-certificates and then
	update CA certificates.
END
}

if [ "$#" -ne 1 ]; then
	usage
	exit 1
fi

if ! cp "$1" /usr/local/share/ca-certificates/; then
	echo "$SCRIPT: could not copy certificate, are you root?" >&2
	exit 1
fi

update-ca-certificates
