I'd like to execute a bash script before my system is rebooted or does a shutdown.
I would need it on several systems:
a) On Domoticz running in Debian to store PHP APCu variables to disk so they can be recovered after boot.
b) To transfer camera records of pikrellcam from raspberry to nas.
These are my systemd config files:
Code: Select all
[Unit]
Description=Saves cache upon reboot and shutdown
After=apache2.service
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/var/www/html/secure/atreboot.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Code: Select all
[Unit]
Description=Saves video's on nas upon reboot and shutdown
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/home/pi/sync2nas.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Problem is that on the Domoticz system the APCu isn't available anymore because apache2 and php-fpm are already stopped.
For the raspberries the script is executed as long as the nas is online. As soon as the sync script needs to wake the nas with wol it takes to long and it isn't finished before reboot.
Any ideas?