5
5
# - Will automatically identify the correct Route 53 zone for each domain name
6
6
# - Supports certificates with alternative names in different Route 53 zones
7
7
#
8
- # This version includes a deploy_cert function for CentOS 6 / RHEL 6 for webmin and apache
8
+ # This version includes a deploy_cert function for CentOS 6 / RHEL 6 / Amazon Linux
9
+ # for webmin, apache, and slapd (Sys V init 'service' command)
9
10
#
10
11
# Aaron Roydhouse <[email protected] >, 2016
11
12
# https://github.com/whereisaaron/dehydrated-route53-hook-script
@@ -100,10 +101,10 @@ deploy_cert() {
100
101
#
101
102
# Restart apache to read the new certificate files
102
103
# Requires that user running dehydrated has sudoer rights to execute the commands, e.g
103
- # dehydrated ALL = NOPASSWD: /sbin/service httpd configtest, /sbin/service httpd graceful
104
+ # dehydrated ALL = NOPASSWD: /sbin/service httpd status, /sbin/service httpd configtest, /sbin/service httpd graceful
104
105
#
105
106
106
- # Only consider restarting if apache if it is installed and running
107
+ # Only consider restarting apache if it is installed and running
107
108
if [[ " $( sudo service httpd status) " =~ " running" ]]; then
108
109
109
110
# Restart apache if the configuration is valid
@@ -117,6 +118,41 @@ deploy_cert() {
117
118
fi
118
119
119
120
fi
121
+
122
+ #
123
+ # Restart slapd (openldap) to read the new certificate files bash on heuristic that domain starts with 'ldap'
124
+ # Requires that user running dehydrated has sudoer rights to execute the commands, e.g
125
+ # dehydrated ALL = NOPASSWD: /sbin/service slapd status, /sbin/service slapd configtest, /sbin/service slapd restart
126
+ #
127
+
128
+ # Only consider restarting slapd if cert starts with ldap
129
+ if [[ " ${DOMAIN} " =~ ^ldap ]]; then
130
+
131
+ # Copy the cert if the target folder exists and it writable
132
+ # Target folder should be set-gid 'ldap' to ensure slapd can read the files
133
+ local LDAP_DEPLOY=/etc/openldap/dehydrated
134
+ if [[ -d " ${LDAP_DEPLOY} " && -w " ${LDAP_DEPLOY} " ]]; then
135
+ echo " Copying slapd cert/key/chain (${KEYFILE} ${CERTFILE} ${CHAINFILE} ) to ${LDAP_DEPLOY} "
136
+ cp " ${KEYFILE} " " ${CERTFILE} " " ${CHAINFILE} " " ${LDAP_DEPLOY} "
137
+ chmod g+r " ${KEYFILE} " " ${CERTFILE} " " ${CHAINFILE} "
138
+ fi
139
+
140
+ # Only consider restarting slapd if it is installed and running
141
+ if [[ " $( sudo service slapd status) " =~ " running" ]]; then
142
+
143
+ # Restart slapd if the configuration is valid
144
+ echo -n " Checking slapd config: "
145
+ sudo service slapd configtest
146
+ if [[ $? -eq 0 ]]; then
147
+ echo " Config OK"
148
+ echo " Restarting slapd to read the new certificate files for ${DOMAIN} "
149
+ sudo service slapd restart
150
+ else
151
+ echo " Config is invalid"
152
+ (>&2 echo " Skipping restarting slapd because slapd config is invalid" )
153
+ fi
154
+ fi
155
+ fi
120
156
}
121
157
122
158
#
0 commit comments