a484e8bdbeaebb306e59544f4851fc16b42c7d6a
Linux/Apache/mod_ssl.md
... | ... | @@ -351,6 +351,35 @@ Kcertbot-key.+165+43987.key, Kcertbot-key.+165+43987.private の2つのファ |
351 | 351 | -d "*.<ドメイン>" -d <ドメイン>
|
352 | 352 | ```
|
353 | 353 | |
354 | +- /etc/cron.weekly/renewCert.sh
|
|
355 | +```bash
|
|
356 | +#!/bin/bash
|
|
357 | +
|
|
358 | +LANG=en_us.UTF-8
|
|
359 | +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
|
|
360 | +dir_letsencrypt=/etc/letsencrypt/live/
|
|
361 | +services="httpd postfix dovecot"
|
|
362 | +
|
|
363 | +check_update() {
|
|
364 | + dir=$1
|
|
365 | + [ $(find ${dir} -mtime -1 -print | wc -l) -gt 1 ]
|
|
366 | +}
|
|
367 | +
|
|
368 | +if [ $(id -u) != 0 ]; then
|
|
369 | + echo "This command requires root previlege." 1>&2
|
|
370 | + exit 1
|
|
371 | +fi
|
|
372 | +
|
|
373 | +certbot renew
|
|
374 | +if check_update ${dir_letsencrypt}; then
|
|
375 | + for service in ${services}; do
|
|
376 | + echo "restart ${service}"
|
|
377 | + systemctl restart ${service} || exit $?
|
|
378 | + done
|
|
379 | +fi
|
|
380 | +exit 0
|
|
381 | +```
|
|
382 | +
|
|
354 | 383 | # 動作確認
|
355 | 384 | |
356 | 385 | ## 証明書の内容をテキスト出力
|