On Feb 28, 2021, at 12:13, Patrick O'Callaghan <pocallaghan@gmail.com> wrote:

Is there a way to invoke scripts before auto-mounting and after auto-
unmounting? I want to be able to power an external drive up and down as
needed.

Your .mount unit would need a Before= and After= Section.  Refer to a systemd .service that you will create that is Type=oneshot, where the ExecStart= powers on the device and ExecStop= powers it off.  I think you’ll need a RemainAfterExit=yes in that service too, so systemd thins it is “up” while the device is powered up.

I don’t know how the power up sequence works, but if the power up command exits before it is powered on, you might need to work some sleep or wait command to only have the service “up” when the device is ready, that way the mount won’t be attempted until it is ready.

— 
Jonathan Billings