docker-ftps/rootfs/app/cron.sh

47 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2022-01-13 07:48:57 +00:00
#!/bin/sh
2024-01-23 16:15:08 +00:00
############ IF ACME IS ENABLED, THIS IS THE WRONG SCRIPT
if [ ! "$ENABLE_ACME" = "1" ] ; then
exit
fi
2022-01-13 07:48:57 +00:00
2024-01-23 16:15:08 +00:00
############ TLS
2022-01-13 07:48:57 +00:00
TLS_CERT=${TLS_CERT:-/certs/cert.pem}
TLS_KEY=${TLS_KEY:-/certs/privkey.pem}
TLS_CHAIN=${TLS_CHAIN:-/certs/chain.pem}
2024-01-23 16:15:08 +00:00
cat "$TLS_CERT" > /etc/proftpd/cert.pem
cat "$TLS_KEY" > /etc/proftpd/privkey.pem
cat "$TLS_CHAIN" > /etc/proftpd/chain.pem
2022-01-13 07:48:57 +00:00
############ IF CERT IS THE SAME, THEN EXIT
2024-01-23 16:15:08 +00:00
md5sum -c /app/sums >/dev/null 2>/dev/null && exit
2022-01-13 07:48:57 +00:00
############ CHECK CERT KEY ALGO
ALGO=$(openssl x509 -in /etc/proftpd/cert.pem -text | sed -n 's/\ *Public Key Algorithm: //p' | tr '\n')
if [ "$ALGO" = "id-ecPublicKey" ] ; then
cat > /etc/proftpd/conf.d/certificate.conf <<EOF
<IfModule mod_tls.c>
TLSECCertificateFile /etc/proftpd/cert.pem
TLSECCertificateKeyFile /etc/proftpd/privkey.pem
TLSCertificateChainFile /etc/proftpd/chain.pem
</IfModule>
EOF
fi
if [ "$ALGO" = "rsaEncryption" ] ; then
cat > /etc/proftpd/conf.d/certificate.conf <<EOF
<IfModule mod_tls.c>
TLSRSACertificateFile /etc/proftpd/cert.pem
TLSRSACertificateKeyFile /etc/proftpd/privkey.pem
TLSCertificateChainFile /etc/proftpd/chain.pem
</IfModule>
EOF
fi
2024-01-23 16:15:08 +00:00
md5sum "$TLS_CERT" > /app/sums
2022-01-13 07:48:57 +00:00
############ RELOAD
killall -HUP proftpd