Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Generate LetsEncrypt certs instead of self signed during install #61

Open
slntopp opened this issue Jan 27, 2021 · 1 comment
Open

Generate LetsEncrypt certs instead of self signed during install #61

slntopp opened this issue Jan 27, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@slntopp
Copy link
Member

slntopp commented Jan 27, 2021

No description provided.

@slntopp slntopp added this to the IONe v1.0.2 - stable milestone Jan 27, 2021
@slntopp slntopp added the enhancement New feature or request label Jan 27, 2021
@slntopp
Copy link
Member Author

slntopp commented Jan 27, 2021

As an example

#!/bin/bash

d1=ssl.example.com
d2=ssl1.example.com
d3=ssl2.example.com
tmpdir="/var/www/letsecrypt"
nginxconf="/etc/nginx/conf.d/example.com.conf"
RSA=/etc/one/ssl/example.com.key
CRT=/etc/one/ssl/example.com.crt
LOG=/root/.acme.sh/acme.sh.log

function configureNginx {

mkdir -p $tmpdir
echo "CONFIGURE NGINX" >> $LOG
\mv $nginxconf "${nginxconf}_backup"

cat << EOF > $nginxconf
server {
        listen                  80;
        server_name             $d1 $d2 $d3;
        root                    $tmpdir;
        location / {
                index index.html;
        }
}
EOF

sleep 1
systemctl restart nginx.service
sleep 1
echo "ISSUE CERT" >> $LOG
/root/.acme.sh/acme.sh --issue -d $d1 -d $d2 -d $d3 -w $tmpdir --force >> $LOG &>>$LOG
\mv "${nginxconf}_backup" $nginxconf
\cp /root/.acme.sh/$d1/$d1.key $RSA
\cp /root/.acme.sh/$d1/fullchain.cer $CRT
sleep 1
systemctl restart nginx.service

}

/usr/sbin/nginx -t 2>/dev/null > /dev/null
if [[ $? == 0 ]]; then
echo "START LE" >> $LOG
configureNginx
echo "FINISH LE" >> $LOG
else
 echo "nginx fail" >> $LOG
fi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant