SYNOPSIS
--------
-*tlsproxy-setup*
+*tlsproxy-setup* ['--force']
DESCRIPTION
It creates the following files in the current directory:
-- proxy-ca.pem
-- proxy-ca-key.pem
-- proxy-dh.pem
-- proxy-key.pem
-- proxy-invalid.pem
+- `proxy-ca.pem`
+- `proxy-ca-key.pem`
+- `proxy-dh.pem`
+- `proxy-key.pem`
+- `proxy-invalid.pem`
+
+If any of these files exist, the program is aborted.
Requires GnuTLS' *certtool*.
set -e
-if test "$#" -ne 0; then
- echo "Usage: $0"
+if test "$#" -ge 1 && test x"$*" != 'x--force'; then
+ echo "Usage: $0 [--force]" >&2
exit 1
fi
+# Prevent accidental overwrites.
+if test x"$1" != 'x--force'; then
+ for x in proxy-ca-key.pem proxy-ca.pem \
+ proxy-key.pem proxy-invalid.pem proxy-dh.pem; do
+ if test -f "$x"; then
+ echo "File '$x' already exists. Use --force to overwrite." >&2
+ exit 2
+ fi
+ done
+fi
+
+
tempfile=`mktemp`
trap 'rm -f "$tempfile"' EXIT