6340d606f88bfbde80b4dcfa97427ec96422be37
[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/certificates/_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/3 * * 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 logfile="/tmp/$(basename $0).log"
31 rm -f $logfile
32
33 function log {
34     echo $1 >> $logfile
35 } # log
36
37 log "Starting $0"
38 log "Restarting nginx on Synology"
39
40 # At this point this is all we need to do. Set up for ssh pre-shared key such that
41 # root on your desktop can ssh into the Synology (jupiter) without a password.
42 #
43 # Note: On DSM 6.x systemctl may be called /usr/syno/sbin/synosystemctl
44 ssh root@jupiter systemctl restart nginx
45
46 log "Nginx restarted"