What do I need to put in the
[install] section, so that systemd runs
/home/me/so.pl right before shutdown and also before
/proc/self/net/dev gets destroyed?
[Unit] Description=Log Traffic [Service] ExecStart=/home/me/so.pl [Install] ?
The suggested solution is to run the service unit as a normal service - have a look at the [Install] section. So everything has to be thought reverse, dependencies too. Because the shutdown order is the reverse startup order. That's why the script has to be placed in ExecStop.
The following solution is working for me:
RemainAfterExit is needed because otherwise the service gets stopped as soon as the start action finishes.
I just got it from systemd IRC, credits are going to mezcalero.
I am not totally sure but i don't think you need the install part though i added it explicitly. I also didn't test it but i think it should help you get started:
As far as I can see this does what I need (but I don't know exactly why).