Aipo に Let's Encrypt の SSL証明書を適用(自動実行編)

前回、Tomcat 上の Aipo の Let's Encrypt SSL 適用の話を書きました。
ここでは(動いているっぽい)crontab 自動実行用のスクリプトを上げておきます。
作業ディレクトリ/etc/letsencrypt/live/aipo.wba-initiative.org/ の下にバックアップ用のディレクトリ backup を作っておきます。
openssl のパスワード指定では接頭辞に pass: を置く必要があるようです。
あとは見ていただければだいたいわかるかと...
crontab は毎週実行させるようにしています。
certbot renew は必要がないときはファイルを更新しません。
certbot renew によるファイル更新がない場合は、そのまま exit します。

#!/bin/bash -l
# Obtaining a pem certificate from Let's Encrypt
/bin/certbot renew
if [ fullchain.pem -ot ssllets.p12 ]; then
  echo "No update is due."
  exit
fi

# Converting pem certificate to p12
cd /etc/letsencrypt/live/aipo.wba-initiative.org/; /bin/openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out ssllets.p12 -password pass:****

# Converting p12 certificate to keystore
cd /etc/letsencrypt/live/aipo.wba-initiative.org/; /usr/local/aipo/jre/bin/keytool -importkeystore -destkeystore ssllets.keystore -srckeystore ssllets.p12 -srcstoretype PKCS12 -srcstorepass **** -deststorepass **** -noprompt

# Replacing the keystore file
fd=`date -r /root/.keystore "+%Y%m%d:%H%M%S"`
cd /etc/letsencrypt/live/aipo.wba-initiative.org; /bin/cp -p /root/.keystore backup/$fd.keystore; /bin/cp -p -f ssllets.keystore /root/.keystore

# Rebooting Aipo
cd  /usr/local/aipo/bin
./shutdown.sh
./startup.sh

Commenti

Post popolari in questo blog

Aipo に Let's Encrypt の SSL証明書を適用

ES611の電池交換

マケドニア語・ブルガリア語同時学習その5(名詞の性と数、後置冠詞形)