Last active
October 8, 2019 00:25
-
-
Save masuidrive/68ef9e612003fe33a23742679ea50794 to your computer and use it in GitHub Desktop.
mydnsのLet's Encryptを設定するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# GROUP=1003 MYDNSJP_DOMAIN=XXXX.mydns.jp MYDNSJP_MASTERID=mydnsXXXXX MYDNSJP_MASTERPWD=XXXX [email protected] sh set_mydns_and_ssl.sh | |
apt install -y php php-mbstring certbot unzip | |
mkdir -p /usr/local/mydns | |
cd /usr/local/mydns | |
wget 'https://github.com/disco-v8/DirectEdit/archive/master.zip' -O DirectEdit-master.zip | |
unzip -f ./DirectEdit-master.zip | |
cd DirectEdit-master | |
cat << EOT > txtedit.conf | |
<?php | |
\$MYDNSJP_URL = 'https://www.mydns.jp/directedit.html'; | |
\$MYDNSJP_MASTERID = '$MYDNSJP_MASTERID'; | |
\$MYDNSJP_MASTERPWD = '$MYDNSJP_MASTERPWD'; | |
\$MYDNSJP_DOMAIN = '$MYDNSJP_DOMAIN'; | |
?> | |
EOT | |
chmod 700 ./*.php | |
chmod 600 ./*.conf | |
certbot certonly --manual \ | |
--preferred-challenges=dns \ | |
--manual-auth-hook /usr/local/mydns/DirectEdit-master/txtregist.php \ | |
--manual-cleanup-hook /usr/local/mydns/DirectEdit-master/txtdelete.php \ | |
-d $MYDNSJP_DOMAIN -d *.$MYDNSJP_DOMAIN \ | |
--server https://acme-v02.api.letsencrypt.org/directory \ | |
--agree-tos -m $EMAIL \ | |
--manual-public-ip-logging-ok | |
chown -R root:$GROUP /etc/letsencrypt/{live,archive} | |
chmod 770 /etc/letsencrypt/{live,archive} | |
cat << EOT > /etc/cron.weekly/certbot | |
#!/bin/sh | |
certbot renew | |
systemctl restart code-server.service | |
EOT | |
chmod a+x /etc/cron.weekly/certbot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment