cert-renewer@.service 1.0 KB

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