<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi Mantas,</div>
<div> </div>
<div>thank you for your helpful input. My main error was probably that I was accidentially using "TimeoutStartSec" instead of "TimeoutStopSec". My current implementation now looks like this:</div>
<div> </div>
<div>
<div>[Unit]<br/>
Description=Wait for backups<br/>
After=ssh.service remote-fs.target rsyslog.service<br/>
Requires=ssh.service remote-fs.target rsyslog.service</div>
<div> </div>
<div>[Service]<br/>
Type=oneshot<br/>
ExecStart=/usr/local/bin/backup_wait start<br/>
ExecStop=/usr/local/bin/backup_wait stop<br/>
TimeoutStopSec=1d<br/>
RemainAfterExit=true</div>
<div> </div>
<div>[Install]<br/>
WantedBy=multi-user.target</div>
<div> </div>
</div>
<div>
<div>I am not really sure about the "Requires" and the "WantedBy". I also added a dependency to rsyslog.service, because without that, logger attempts in "backup_wait" are not written to the syslog. Is there a better way to achieve this?</div>
<div> </div>
<div>Now I try to integrate plymouth. I had a look to /lib/systemd/system/casper.service, which is used in a "live cd" setup to show to "Please remove the installation medium" message.</div>
<div> </div>
<div>For me it looks like this service is using a different strategy? I understand the current approach of my service: "shutdown in the opposit order than startup". But in casper there is a "After=shutdown.target ...". Is this target part of the boot procedure?</div>
<div> </div>
<div>Maybe you can help me in transfering the plymouth bits of the casper service into my service? (Just adding casper.services' After dependencies did not work...)</div>
<div> </div>
<div>Best regards</div>
<div>Henning</div>
<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Montag, 29. August 2022 um 14:01 Uhr<br/>
<b>Von:</b> "Mantas Mikulėnas" <grawity@gmail.com><br/>
<b>An:</b> "Henning Moll" <newsScott@gmx.de><br/>
<b>Cc:</b> "Systemd" <systemd-devel@lists.freedesktop.org><br/>
<b>Betreff:</b> Re: [systemd-devel] Help required for configuring a blocking service during shutdown</div>
<div name="quoted-content">
<div>
<div class="gmail_quote">
<div class="gmail_attr">On Mon, Aug 29, 2022 at 1:31 PM Henning Moll <<a href="mailto:newsScott@gmx.de" onclick="parent.window.location.href='mailto:newsScott@gmx.de'; return false;" target="_blank">newsScott@gmx.de</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;">
<div>
<div style="font-family: Verdana;font-size: 12.0px;">
<div>Hi,</div>
<div> </div>
<div>back in the rcX days I configured a backup system which blocks a system shutdown in a certain state (network and mounts still active) if a backup is still running. The init script looks like this:</div>
<div> </div>
<div>...</div>
<div>
<div>case "$1" in</div>
<div>...</div>
<div>
<div> stop) <br/>
plymouth --ping<br/>
if [ $? -ne 0 ]; then<br/>
log_daemon_msg "waiting for running backup" "backup"<br/>
else<br/>
plymouth message --text="waiting for running backup"<br/>
fi<br/>
sleep 10<br/>
logger -t backup "rcS: trying to get lock..."<br/>
exec {FD}<>"$LOCKFILE"<br/>
{<br/>
logger -t backup "locked rsync_wrapper: waiting for lock"<br/>
flock ${FD}<br/>
}<br/>
logger -t backup "rcS: continue shutdown..."<br/>
plymouth message --text=""</div>
<div> </div>
<div>...<br/>
esac</div>
<div>...</div>
</div>
<div> </div>
<div>The strategy is to wait for a successful lock on a shared LOCKFILE.</div>
<div> </div>
<div>Now, I want to solve this with systemd. I've read tons of documentation but I don't get it, all my experiments failed. I am using Linux Mint 21 "Vanessa", which is based on Ubunut 22.04.</div>
<div> </div>
<div>I am looking for a solution which</div>
<div> </div>
<div>* "pauses" a shutdown or reboot attempt as long as the LOCK cannot be obtained (which means the backup is still running)</div>
<div>* while the network connection (ethernet) is still active</div>
<div>* and all mounts (local, usb and cifs) are still active</div>
<div>* openssh-server still running</div>
<div>* The logging functionality (plymouth / log_daemon) would be nice. so the system should be allowed to shutdown to a stage where plymouth is already visible</div>
<div> </div>
<div>Can you please help me?</div>
<div> </div>
<div>Best regards</div>
<div>Henning</div>
</div>
</div>
</div>
</blockquote>
</div>
<div> </div>
<div>Probably similar to what you already have – create a service that starts on boot (doing nothing) and delays the *stop* action. (You'll probably need to start with [Service] Type=oneshot, RemainAfterExit=yes, TimeoutStopSec=1d.) If you list After=ssh.service as a dependency, then your service will be started after OpenSSH and *stopped before OpenSSH*, same with NetworkManager. (I'm not sure if there's a dependency that can be used to target manually done SMB mounts, although remote-fs.target might work for the ones in fstab?)</div>
<div> </div>
<div>Not sure how it works with Plymouth, but in its default console output, systemd itself will already show which services are waiting to be stopped. Syslog (journald) should be available the entire time.</div>
<div> </div>
<div>The backup system should also run under `systemd-inhibit --what=shutdown` as an additional layer of precaution – that way the user will know that something is still running *before* they initiate the actual shutdown.</div>
<br/>
--
<div class="gmail_signature">
<div>Mantas Mikulėnas</div>
</div>
</div>
</div>
</div>
</div>
</div></div></body></html>