45 lines
1.2 KiB
Bash
45 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
H_NAME=$( hostname -f )
|
||
|
LE_CERTS_DIR=/var/lib/acme/live/$H_NAME
|
||
|
LE_LOG_DIR=/var/log/letsencrypt
|
||
|
LE_LOG_FILE="${LE_LOG_DIR}/mysql.log"
|
||
|
MYSQL_CERTDIR=/var/lib/mysql
|
||
|
|
||
|
DATE=$( date )
|
||
|
|
||
|
[ ! -d $LE_LOG_DIR ] && mkdir $LE_LOG_DIR
|
||
|
echo "$DATE" >> $LE_LOG_FILE
|
||
|
|
||
|
if [ -f "/etc/default/acme_sh_request_env" ] ; then
|
||
|
# shellcheck source=/etc/default/acme_sh_request_env
|
||
|
source "/etc/default/acme_sh_request_env"
|
||
|
else
|
||
|
echo "No letsencrypt default file" >> $LE_LOG_FILE
|
||
|
fi
|
||
|
|
||
|
echo "Copying the cert files" >> $LE_LOG_FILE
|
||
|
if [ ! -f ${MYSQL_CERTDIR}/ca.pem ] ; then
|
||
|
/bin/cp -f "${LE_CERTS_DIR}/fullchain" ${MYSQL_CERTDIR}/ca.pem
|
||
|
chown mysql:mysql ${MYSQL_CERTDIR}/ca.pem
|
||
|
fi
|
||
|
|
||
|
/bin/cp -f "${LE_CERTS_DIR}/privkey" ${MYSQL_CERTDIR}/client-key.pem
|
||
|
chmod 400 ${MYSQL_CERTDIR}/client-key.pem
|
||
|
chown mysql:mysql ${MYSQL_CERTDIR}/client-key.pem
|
||
|
|
||
|
/bin/cp -f "${LE_CERTS_DIR}/cert" ${MYSQL_CERTDIR}/client-cert.pem
|
||
|
chmod 440 ${MYSQL_CERTDIR}/client-cert.pem
|
||
|
chown mysql:mysql ${MYSQL_CERTDIR}/client-cert.pem
|
||
|
|
||
|
echo "Reload the mysql service" >> $LE_LOG_FILE
|
||
|
if [ -x /bin/systemctl ] ; then
|
||
|
systemctl reload mysql >> $LE_LOG_FILE 2>&1
|
||
|
else
|
||
|
service mysql reload >> $LE_LOG_FILE 2>&1
|
||
|
fi
|
||
|
|
||
|
echo "Done." >> $LE_LOG_FILE
|
||
|
|
||
|
exit 0
|