Hopefully final adjustments to certbot
[clearscm.git] / bin / certbot_deploy.sh
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         certbot_deploy.sh
5 # Revision:     1.0
6 # Description:  Deploy the new certs. This script is run to deploy the new certs
7 #               onto the Synology. We should have already obtained new Let's
8 #               Encrypt certs and have placed them into /System/Certificates.
9 #               Now we just need to restart nginx on the Synology. This works
10 #               because /usr/syno/etc/certificate/_archive already has been
11 #               configured to look at /System/Certificates for new certs.
12 #
13 #               The restarting of nginx on Synology is large and takes time. You
14 #               will not be able to get into the DSM web page and Docker will
15 #               restart. Be patient and it should come back up with the new certs
16 #               active.
17 #
18 # See also:     https://help.dreamhost.com/hc/en-us/articles/217555707-DNS-API-commands
19 #
20 # Crontab:      0 0 20 Jan,Apr,Jul,Oct * certbot renew
21 #
22 # Author:       Andrew@DeFaria.com
23 # Created:      Mon Oct 24 11:53:38 AM PDT 2022
24 # Modified:
25 # Language:     Bash
26 #
27 # (c) Copyright 2021, ClearSCM, Inc., all rights reserved
28 #
29 ################################################################################
30 certdir="/System/Certificates"
31
32 mkdir -p $certdir
33
34 logfile="$certdir/$(basename $0).log"
35
36 rm -f $logfile
37
38 function log {
39     echo $1 >> $logfile
40 } # log
41
42 log "Starting $0"
43 log "Restarting nginx on Synology"
44
45 # At this point this is all we need to do. Set up for ssh pre-shared key such that
46 # root on your desktop can ssh into the Synology (jupiter) without a password.
47 #
48 # Note: On DSM 6.x systemctl may be called /usr/syno/sbin/synosystemctl
49 ssh root@jupiter systemctl restart nginx
50
51 log "Nginx restarted"