2021-01-28 01:29:29 +00:00
|
|
|
[Unit]
|
|
|
|
Description=Certificate renewer for %I
|
|
|
|
After=network-online.target
|
|
|
|
Documentation=https://smallstep.com/docs/step-ca/certificate-authority-server-production
|
|
|
|
StartLimitIntervalSec=0
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
User=root
|
|
|
|
|
|
|
|
Environment=STEPPATH=/etc/step-ca \
|
|
|
|
CERT_LOCATION=/etc/step/certs/%i.crt \
|
|
|
|
KEY_LOCATION=/etc/step/certs/%i.key
|
|
|
|
|
2021-07-21 16:49:10 +00:00
|
|
|
; ExecCondition checks if the certificate is ready for renewal,
|
2021-01-28 01:29:29 +00:00
|
|
|
; based on the exit status of the command.
|
2021-07-21 16:49:10 +00:00
|
|
|
; (In systemd 242 or below, you can use ExecStartPre= here.)
|
2021-09-22 00:23:29 +00:00
|
|
|
ExecCondition=/usr/bin/step certificate needs-renewal ${CERT_LOCATION}
|
2021-01-28 01:29:29 +00:00
|
|
|
|
|
|
|
; ExecStart renews the certificate, if ExecStartPre was successful.
|
2021-09-22 00:23:29 +00:00
|
|
|
ExecStart=/usr/bin/step ca renew --force ${CERT_LOCATION} ${KEY_LOCATION}
|
2021-01-28 01:29:29 +00:00
|
|
|
|
|
|
|
; Try to reload or restart the systemd service that relies on this cert-renewer
|
2021-03-17 00:08:20 +00:00
|
|
|
; If the relying service doesn't exist, forge ahead.
|
2021-11-22 19:03:05 +00:00
|
|
|
ExecStartPost=/usr/bin/env sh -c "! systemctl --quiet is-enabled %i.service || systemctl try-reload-or-restart %i"
|
2021-01-28 01:29:29 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|