I‘m running a host with x86-64 Arch Linux with Plasma with latest updates. Here I contact a NAS with wakeonlan, which works fine, so that I can mount an nfs and a Samba share after successful pinging the NAS.
This is done with a systemd service, started (enabled) when booting my host (tuxarch). I have installed an Arch OS for arm processors on my NAS. With the correct permissions on my remote NAS, I can shutdown (systemctl poweroff) this NAS via ssh from host tuxarch. I have a small batch file in which I unmount the nfs and the cifs mounted shares and after unmounting I send the "systemctl poweroff" command via ssh. This batch file does, what I expect and finally the NAS is shut down, powered off.
Now I want to execute this batch file just before shutting down my host via systemd service with still mounted shares (to unmount them safely) and still established network connection to the remote NAS to finally send the command „sudo -u tuxuser ssh -t [email protected] 'sudo systemctl poweroff'“ to shutdown (Poweroff) my NAS.
For this I created several different shutdown.Zyxel.NAS.service (s). One at one time, next with adoptions. To test and activate the actual service I do not enable this service, I just START the service with: systemctl start shutdown.Zyxel.NAS.service. Now, my problem is, that the batch file is executed immidiately when the service is started instead of wait until shutdown is triggered. I have tried several configurations of such services, here is my last one:
systemctl cat shutdown.Zyxel.NAS
/etc/systemd/system/shutdown.Zyxel.NAS.service
[Unit]
Description=Shutdown Remote Zyxel NAS
DefaultDependencies=no
Requires=network-online.target
RequiresMountsFor=/mnt/Zyxel-Nas
After=final.target
[Service]
User=tuxuser
Group=tuxuser
ExecStart=/home/tuxuser/ssh.Zyxel.NAS.poweroff.sh
Type=oneshot
[Install]
WantedBy=final.target[/code]
So, as I said, the service starts the batch file in /home/tuxuser immediately. What is wrong in my shutdown.Zyxel.Nas.service? I wonder, why this service does not hesitate until the signal to begin shutdown process is send. Any help, any good suggestion is appreciated.
Thank you in advance!
-Linuxwhisperer