상태
Let 's Encrypt의 인증서를 갱신하기 위해 사용자 지정 시스템 서비스 단위와 해당 셸 스크립트를 작성했습니다 . 내가 달리면 모든 것이 잘 작동합니다 systemctl start letsencrypt-example_com.service
. 60 일마다 자동으로 실행되기를 원하므로 시스템 타이머 장치를 작성했습니다.
발행물
나는 systemctl enable letsencrypt-example_com.timer
그때 달렸다 systemctl start letsencrypt-example_com.timer
. 타이머가 시작되었지만 서비스가 아닌 것 같습니다.
# systemctl status letsencrypt-example_com.timer
Created symlink from /etc/systemd/system/timers.target.wants/letsencrypt-example_com.timer to /etc/systemd/system/letsencrypt-example_com.timer.
# systemctl start letsencrypt-example_com.timer
# systemctl list-timers --all
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
n/a n/a ven. 2016-05-06 13:10:13 CEST 1h 51min ago letsencrypt-example_com.timer letsencrypt-example_com.service
# systemctl status letsencrypt-example_com.timer
● letsencrypt-example_com.timer - Run letsencrypt-example_com every 60 days
Loaded: loaded (/etc/systemd/system/letsencrypt-example_com.timer; enabled)
Active: active (elapsed) since ven. 2016-05-06 15:01:57 CEST; 2min 50s ago
# systemctl status letsencrypt-example_com.service
● letsencrypt-example_com.service - letsencrypt certificat renewal for example.com and subdomains
Loaded: loaded (/etc/systemd/system/letsencrypt-example_com.service; static)
Active: inactive (dead)
파일
cat /etc/systemd/system/letsencrypt-example_com.service
:
[Unit]
Description=letsencrypt certificat renewal for example.com and subdomains
Requires=nginx_reload.service
Before=nginx_reload.service
[Service]
Type=simple
ExecStart=/bin/sh /usr/local/bin/letsencrypt-renew.sh example.com www.example.com
User=letsencrypt
Group=www-data
/usr/local/bin/letsencrypt-renew.sh
:
#!/bin/sh
letsencrypt certonly \
--server https://acme-v01.api.letsencrypt.org/directory \
--text \
--email admin@example.com \
--agree-tos \
--rsa-key-size 4096 \
--authenticator webroot \
--webroot-path /srv/files/letsencrypt/www \
$(
for fqdn in $@;
do echo "--domain $fqdn";
done;
) \
--force-renew
/etc/systemd/system/letsencrypt-example_com.timer
:
[Unit]
Description=Run letsencrypt-example_com every 60 days
[Timer]
OnUnitActiveSec=1min
Persistent=true
Unit=letsencrypt-example_com.service
[Install]
WantedBy=timers.target
/etc/systemd/system/nginx_reload.service
:
[Unit]
Description=reload nginx conf
[Service]
Type=oneshot
ExecStart=/bin/systemctl reload nginx
—
nh2
nginx_reload.service
, 및이 추가letsencrypt-example_com.service instead
:PermissionsStartOnly=true
ExecStartPost=/bin/systemctl reload nginx