You are not logged in.

#1 2023-01-30 20:13:54

Al.Piotrowicz
Member
Registered: 2017-08-07
Posts: 130

systemd script start on manual mount

I'd like to create systemd service which executes the script after the manual localfs (/test) location mount (console command), googled it but without success.

My service:

[Unit]
Requires=udisks2.service
Requires=graphical.target
After=graphical.target
After=test.mount
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/bash /home/user/rsync_back
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
ReadWritePaths=/test/
ProtectControlGroups=true
ProtectHome=false
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectProc=noaccess
ProtectSystem=strict
[Install]
WantedBy=graphical.target

It starts and failed right after boot with:

sty 30 20:18:56 rebro systemd[1459]: boot_backup.service: Failed to set up mount namespacing: /run/systemd/unit-root/test: No such file or directory
sty 30 20:18:56 rebro systemd[1459]: boot_backup.service: Failed at step NAMESPACE spawning /bin/bash: No such file or directory
sty 30 20:18:56 rebro systemd[1]: boot_backup.service: Main process exited, code=exited, status=226/NAMESPACE
sty 30 20:18:56 rebro systemd[1]: boot_backup.service: Failed with result 'exit-code'.
sty 30 20:18:56 rebro systemd[1]: Failed to start boot_backup.service.

I've read to archive such an effect, I need to configure systemd timer make to wait for the manual activation of my test.mount, but I don't know how. I'm pretty sure some experienced systemd user could narrow me on the point easily. Thanks.

EDIT: Typo fix

Last edited by Al.Piotrowicz (2023-01-30 20:39:56)

Offline

#2 2023-01-30 20:27:28

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,513
Website

Re: systemd script start on manual mount

Is your service really lacking a [Unit] header or is that a transcription error?

And I think you might need this line in the [Unit] section:

Wants=test.mount

Freedom for Öcalan!

Offline

#3 2023-01-30 20:40:16

Al.Piotrowicz
Member
Registered: 2017-08-07
Posts: 130

Re: systemd script start on manual mount

Thanks. I'll try that.

Offline

#4 2023-01-31 16:24:07

Al.Piotrowicz
Member
Registered: 2017-08-07
Posts: 130

Re: systemd script start on manual mount

Head_on_a_Stick wrote:

Is your service really lacking a [Unit] header or is that a transcription error?

And I think you might need this line in the [Unit] section:

Wants=test.mount

Tried that suggestion. It doesn't change systemd behavior. It fails the same way before. I wish it would act likewise my manual command triggers the "listening" boot_backup.service. Is it possible?

Offline

#5 2023-01-31 16:31:20

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: systemd script start on manual mount

If you're going to be manually mounting the filesystem in the first place why not just add the relevant mount command to the beginning of your script and call that instead?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2023-01-31 16:37:14

Al.Piotrowicz
Member
Registered: 2017-08-07
Posts: 130

Re: systemd script start on manual mount

Slithery wrote:

If you're going to be manually mounting the filesystem in the first place why not just add the relevant mount command to the beginning of your script and call that instead?

I have to agree, that would be a logical step. lol

Offline

Board footer

Powered by FluxBB