# Let's Encrypt post-hook

**URL:** <https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399>\
**Category:** Virtualmin\
**Created:** [October 18, 2022, 12:43pm UTC](https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399 "2022-10-18T12:43:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deanski79](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/d/ecd19e/32.png) [@deanski79](https://forum.virtualmin.com/u/deanski79)\
**Post date:** [October 18, 2022, 12:43pm UTC](https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399/1 "2022-10-18T12:43:00Z")

</div>

Hi guys,

Is there any way to add “post-hook” action on SSL renewal? I looked everywhere and seems like there is no such option. The reason I’m asking is that I am using few custom services and I need them to be restarted to apply the new ssl certificates.

In my other setups I am using certbot --post-hook feature, but in Virtualmin there is no such option.

Is there an easy way to achieve this?

Kind regards,  
Dean

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 18, 2022, 5:25pm UTC](https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399/2 "2022-10-18T17:25:46Z")

</div>

Hello, Dean!

> Is there any way to add “post-hook” action on SSL renewal?

Yes, it is possible.

You should define a `Command to run after making changes to a server` in `System Settings ⇾ Virtualmin Configuration / Actions upon server and user creation` to point to a custom script, let’s say `/usr/local/sbin/virtualmin-post-server.sh` and there do something like this:

```auto
#!/bin/sh
if ["$VIRTUALSERVER_ACTION" = "SSL_DOMAIN"]; then
  # Update SSL certificates for Prosody
  /usr/bin/cp -f /home/$VIRTUALSERVER_DOM/ssl.key /etc/prosody/certs/$VIRTUALSERVER_DOM.key
  /usr/bin/cp -f /home/$VIRTUALSERVER_DOM/ssl.bundle /etc/prosody/certs/$VIRTUALSERVER_DOM.bundle
  /usr/bin/chmod 700 /etc/prosody/certs/$VIRTUALSERVER_DOM.bundle /etc/prosody/certs/$VIRTUALSERVER_DOM.key
  /usr/bin/chown prosody:prosody /etc/prosody/certs/$VIRTUALSERVER_DOM.key /etc/prosody/certs/$VIRTUALSERVER_DOM.bundle
  /usr/bin/systemctl restart prosody.service

  # Print all available env vars for a script
  /usr/bin/printenv > /root/virtualmin-all-envs
fi

```

---

<div class="post-metadata">

**Author:** ![deanski79](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/d/ecd19e/32.png) [@deanski79](https://forum.virtualmin.com/u/deanski79)\
**Post date:** [October 21, 2022, 8:27am UTC](https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399/3 "2022-10-21T08:27:03Z")

</div>

Hello, Ilia!

Thank you for this, I already have seen this, but I thought this is only done when you create new users/domains/etc.

I will try this and update this ticket if needed.

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [December 20, 2022, 8:27am UTC](https://forum.virtualmin.com/t/lets-encrypt-post-hook/117399/4 "2022-12-20T08:27:34Z")

</div>

Closed on December 20, 2022, 8:27am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
