-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_cert
More file actions
executable file
·48 lines (38 loc) · 1.76 KB
/
update_cert
File metadata and controls
executable file
·48 lines (38 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
if [[ $FQDN == *"."* ]]; then
if pgrep -x "httpd" > /dev/null; then
"APACHE ALREADY RUNNING"
else
"APACHE NOT RUNNING, STARTING..."
apachectl
sleep 2
fi
sed -i 's/^#ServerName/ServerName/g' /etc/httpd/conf.d/ssl.conf
sed -i 's/^#SSLCertificateChainFile/SSLCertificateChainFile/g' /etc/httpd/conf.d/ssl.conf
sed -i 's/^#ServerName/ServerName/g' /etc/httpd/conf/httpd.conf
sed -i 's/^ServerName .*/ServerName '"$FQDN"'/g' /etc/httpd/conf.d/ssl.conf
sed -i 's/^ServerName .*/ServerName '"$FQDN"'/g' /etc/httpd/conf/httpd.conf
certbot certonly --webroot -n --webroot-path /var/www --preferred-challenges http-01 -d $FQDN -m vera@genomics.fsu.edu --agree-tos
certExitStatus=$?
if [ $certExitStatus -eq 0 ]; then
KEYLOC=/etc/letsencrypt/live/${FQDN}/privkey.pem
CRTLOC=/etc/letsencrypt/live/${FQDN}/cert.pem
CHNLOC=/etc/letsencrypt/live/${FQDN}/chain.pem
ln -fs $KEYLOC /etc/pki/tls/private/key.pem
ln -fs $CRTLOC /etc/pki/tls/private/crt.pem
ln -fs $CHNLOC /etc/pki/tls/private/chn.pem
sed -i 's#^SSLCertificateFile .*#SSLCertificateFile /etc/pki/tls/private/crt\.pem#g' /etc/httpd/conf.d/ssl.conf
sed -i 's#^SSLCertificateKeyFile .*#SSLCertificateKeyFile /etc/pki/tls/private/key\.pem#g' /etc/httpd/conf.d/ssl.conf
sed -i 's#^SSLCertificateChainFile .*#SSLCertificateChainFile /etc/pki/tls/private/chn\.pem#g' /etc/httpd/conf.d/ssl.conf
#force https
#echo -e 'RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]' >> /etc/httpd/conf/httpd.conf
apachectl -k graceful-stop
sleep 2
apachectl
#APID=$(ps -C httpd | awk 'NR==2{print $1}')
else
echo "OBTAINING SSL CERTIFICATE FAILED!!!!!"
fi
else
echo "NO FQDN SPECIFIED FOR SSL"
fi