This question was asked twice, my apologies. The solution was supplied by Ingo here:
I would like to configure my RPI4 to perform an orderly shutdown if the Ethernet state becomes disconnected.
I would also like it to boot back on if the state becomes connected before power is cut from the device.
It would of course come back on its own when power is restored.
Is this possible?
To give some background, the RPI is being used to record video from several IP cameras on my motorcycle and store them on a USB 256gig M.2 drive. This is also the boot device.
The plan is as follows:
The system is powered by two timed relays, a 10 min and a 5 min relay. When the motorcycle is shut off the relays keep the system powered on at full recording video for 5 min, then the first relay shuts off killing the cameras and the network hub. This is when the RPI would detect the state change of the ETH port and perform an orderly shutdown. 5 min after this the second relay shuts everything off to achieve a fully non powered state.
When I fire the bike back up, everything gets power and the RPI boots up.
IF however I come back to the bike and start it up while its in the second 5 min state, where the RPI has shut down but is still powered on I would like the system to see the change in state of the ETH as coming back and boot up the RPI. This is important as without this part of the code there is a chance the RPI will just sit there in a shutdown but powered on state doing nothing.
I am not a programmer so this is a bit beyond my skills, I am hoping some kind soul can assist.