More (and better) variables

This commit is contained in:
Jack-Benny Persson 2020-04-25 11:50:08 +02:00
parent 4c9dbfce50
commit 6b24c3daac
2 changed files with 36 additions and 17 deletions

View File

@ -6,8 +6,9 @@ services:
context: ./image-files context: ./image-files
dockerfile: Dockerfile dockerfile: Dockerfile
environment: environment:
- HOST= - CN=
- MASTERHOST= - ZONE=
- MASTERPORT=5665 - PARENTHOST=
- PARENTCN=
- PARENTZONE= - PARENTZONE=
- TICKET= - TICKET=

View File

@ -1,19 +1,37 @@
#!/bin/bash #!/bin/bash
icinga2 pki new-cert --cn $HOST \
--key /var/lib/icinga2/certs/${HOST}.key \
--cert /var/lib/icinga2/certs/${HOST}.crt
icinga2 pki save-cert --key /var/lib/icinga2/certs/${HOST}.key \ # If parent cn is not specified, default it to the parent host.
--cert /var/lib/icinga2/certs/${HOST}.crt \ # If the zone if not specified, default it to the cn of the satellite/agent.
--trustedcert /var/lib/icinga2/certs/${MASTERHOST}.crt \ # Use the default port if none is specified.
--host ${MASTERHOST}
icinga2 node setup --ticket $TICKET \ if [ -z "$PARENTCN" ]; then
--cn $HOST \ PARENTCN="$PARENTHOST"
--endpoint ${MASTERHOST},${MASTERHOST},${MASTERPORT} \ fi
--zone $HOST \
--parent_zone $PARENTZONE \ if [ -z "$ZONE" ]; then
--parent_host $MASTERHOST \ ZONE="$CN"
--trustedcert /var/lib/icinga2/certs/${MASTERHOST}.crt \ fi
if [ -z "$PARENTPORT" ]; then
PARENTPORT=5665
fi
icinga2 pki new-cert --cn "$CN" \
--key /var/lib/icinga2/certs/"${CN}".key \
--cert /var/lib/icinga2/certs/"${CN}".crt
icinga2 pki save-cert --key /var/lib/icinga2/certs/"${CN}".key \
--cert /var/lib/icinga2/certs/"${CN}".crt \
--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \
--host "${PARENTHOST}"
icinga2 node setup --ticket "$TICKET" \
--cn "$CN" \
--endpoint "${PARENTCN}","${PARENTHOST}","${PARENTPORT}" \
--zone "$ZONE" \
--parent_zone "$PARENTZONE" \
--parent_host "$PARENTHOST" \
--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \
--accept-commands --accept-config \ --accept-commands --accept-config \
--disable-confd --disable-confd