Hello,

I have been trying to create a system service that would run a script on shutdown (hence why I went for a system service over a user service) and landed on something like this

[Unit]
Description=Run backup script on shutdown
DefaultDependencies=no
Before=poweroff.target halt.target
Requires=network.target

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/var/home/blackeco/scripts/backup.sh
User=blackeco
Group=blackeco

[Install]
WantedBy=poweroff.target halt.target

Unfortunately, when the shutdown occurs, systemd fails to execute the script:

backup-on-shutdown.service: Unable to locate executable '/var/home/blackeco/scripts/backup.sh': Permission denied
backup-on-shutdown.service: Failed at step EXEC spawning /var/home/blackeco/scripts/backup.sh: Permission denied

This script is correctly owned by user blackeco and permissions look fine

$ ls -la /var/home/blackeco/scripts
drwxr-xr-x. 1 blackeco blackeco 154  5 Feb. 13:50 ./
drwxr-xr-x. 1 blackeco blackeco 116  3 Feb. 13:07 ../
-rwxr-xr-x. 1 blackeco blackeco 794  4 Feb. 15:44 backup.sh*

I’m very puzzled as to why. I’m running Bluefin 41 (itself based on Fedora Silverblue 41).

  • Kerb@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    2 days ago

    is your home folder actually under /var/home/… not under /home/… ?

    does the scripr run correctly when you paste the full path in the comandline?

    • Leaflet@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 days ago

      Fedora Atomic, and by extension Universal Blue, does put the home in /var. It’s to denote that the directory is mutable.

    • BlackEco@lemmy.blackeco.comOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 days ago

      is your home folder actually under /var/home/… not under /home/… ?

      Yep, it’s how Silverblue is set up

      $ ls -l /home
      lrwxrwxrwx. 4 root root 8 28 janv. 13:51 /home -> var/home/
      

      does the scripr run correctly when you paste the full path in the comandline?

      Yes