Is there a way to run a script on shutdown, after the file system is remounted as read-only?
I've a raspberry pi connected to a wireless socket, which I can control via a sender and a script. I want to power off that socket (powering off the raspberry) on shutdown, after the file system is mounted read-only.
I've tried this:
[Unit] Description=Test DefaultDependencies=no Requires=shutdown.target umount.target final.target After=shutdown.target umount.target final.target [Service] Type=oneshot ExecStart=/test KillMode=none [Install] WantedBy=halt.target
The script /test does output the current mounts. When it's run on shutdown, it states read/write for the root file system and not read-only as expected.
Content of /test:
#!/bin/bash echo -n 'Debug-Mount: ' > /dev/tty1 cat /proc/mounts | grep /dev/sda > /dev/tty1
Screen output on shutdown: