I am trying to get a bash script called every time a new NFS client connects to my ubuntu NFS server.
I explored the NFSd configuration / exports and also FirewallD’s (this is an ubuntu server but I removed uwf and I use firewalld in it) but couldn’t find any ‘hook’ that I could leverage to get the script to automatically be called.
The reason I want this is that my script resets a timer that I use internally on this server that prevents it from going to sleep; if there are no connections, the server can safely suspend. This script runs on cron on it’s own every few minutes, checks if there are NFS connections active, and if so then it prevents the server from going to sleep by resetting a ‘sleep timer’ (this sleep timer is kodi’s sleep timer, in case anybody is wondering);. This scheme fails whenever a new NFS connection comes at a time when the ‘sleep timer’ is expiring in less time than the interval between cron calls to my script.
My thinking to fix this is that in addition to the cron job (which is currently called every 2 minutes) I can call the same ‘sleep timer reset script’ whenever a new NFS client connects to the server. That way there would be no way for the server to suspend while a client is connected – other than a very very slight chance of the server suspending at exactly the same time a new client is connecting, but I can live with that corner case.