aboutsummaryrefslogtreecommitdiffstats
path: root/init.sh
blob: 3c9de046189d7f6a30914a7dfd8be526f78ad475 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# This source code is released into the public domain.

_PROGNAME="$0"

_fatal() {
	local _fmt=$1; shift
	local _msg="$(printf "$_fmt" "$@")"
	printf >&2 '%s: FATAL: %s\n' "$_PROGNAME" "$_msg"
	exit 1
}

_error() {
	local _fmt=$1; shift
	local _msg="$(printf "$_fmt" "$@")"
	printf >&2 '%s: ERROR: %s\n' "$_PROGNAME" "$_msg"
}

_warn() {
	local _fmt=$1; shift
	local _msg="$(printf "$_fmt" "$@")"
	printf >&2 '%s: WARNING: %s\n' "$_PROGNAME" "$_msg"
}

# The prefix we're installed in.
_BASEDIR="/usr/local"
# Where the internal scripts are.
_SHARE="${_BASEDIR}/share/lfacme"

# Our configuration directory.  This might be overridden by command-line
# arguments.
if [ -z "$_CONFDIR" ]; then
	_CONFDIR="${_BASEDIR}/etc/lfacme"
fi

# Our configuration file.
_CONFIG="${_CONFDIR}/acme.conf"

# Read and validate the configuration file.

if ! [ -f "$_CONFIG" ]; then
	_fatal "missing %s" "$_CONFIG"
fi

. "$_CONFIG"

if [ -z "$ACME_URL" ]; then
	_fatal "ACME_URL must be set in %s" "$_CONFIG"
fi

if [ -z "$ACME_DATADIR" ]; then
	ACME_DATADIR="/var/db/lfacme"
fi

if [ -z "$ACME_KERBEROS_PRINCIPAL" ]; then
	ACME_KERBEROS_PRINCIPAL="host/$(hostname)"
fi

if [ -z "$ACME_HOOKDIR" ]; then
	ACME_HOOKDIR="${ACME_CONFDIR}/hooks"
fi

# The domains.conf file.
_DOMAINS="${_CONFDIR}/domains.conf"

# uacme's base directory; this is where it puts certificates.
_UACME_DIR="${ACME_DATADIR}/certs"

# The uacme executable.
_UACME=/usr/local/bin/uacme

_uacme() {
	"$_UACME" -a "$ACME_URL" -c "$_UACME_DIR" "$@"
}