Autogenerate pkcs12 cert

Hi, I would like you to autogenerate pkcs12 certs when letsencrypt certs are generated or renewed.
What I do is to run the following script in cron.monthly, but it’s a manual procedure at first (I’m migrating my rpi3 to latest version of dietpi from v159)
With the pkcs12 cert generated I can secure PlexMediaServer.

The script I use is:


DOMAIN=$(head -n 1 /DietPi/dietpi/.dietpi-letsencrypt)

openssl pkcs12 -export -in $certdir/fullchain.pem -inkey $certdir/privkey.pem -out $certdir/cert_and_key.p12 -name dietpi -CAfile $certdir/chain.pem -caname root -password pass:aaa

If possible, it would be interesting also to change that password for the certificate (aaa) to use the system password.