Debian Codegraph @

scripts/create-kxd-config

raw symbols SCIP
1 #!/bin/bash
2 #
3 # Create a basic but functional kxd configuration.
4 #
5 # This script creates the /etc/kxd directory, and generates a certificate for
6 # the server to use.
7 #
8 # It should be run under the same user as kxd itself.
9
10 if [ "$1" == "" ]; then
11 echo "Usage: $0 <hostname>"
12 exit 1
13 fi
14
15 set -e
16
17 # Create the base configuration directory.
18 echo "Creating directories (/etc/kxd/)"
19 mkdir -p /etc/kxd/
20
21 # And the data directory where the keys are stored.
22 mkdir -p /etc/kxd/data
23
24 # Create a private key for the server.
25 if ! [ -e /etc/kxd/key.pem ]; then
26 kxgencert \
27 -host "${1?}" \
28 -organization "kxd@$HOSTNAME" \
29 -key /etc/kxd/key.pem \
30 -cert /etc/kxd/cert.pem
31 chmod 400 /etc/kxd/key.pem
32 else
33 echo "Private key already exists (/etc/kxd/key.pem)"
34 fi