You are not logged in.
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
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
Thanks. I'll try that.
Offline
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
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?
Offline
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.
Offline