RemainAfterExit 不起作用

RemainAfterExit 不起作用

我有一个 systemd 服务单元,我想为其启用RemainAfterExit.这在自定义 intrd 中运行。这是我的单位:

[Unit]
Description=Ask for network config
Conflicts=initrd-switch-root.target
Before=initrd-switch-root.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ask_network_config
StandardInput=tty-force
StandardOutput=inherit

你可以看到我已经启用了RemainAfterExit,并且Typeoneshot。然而,一旦脚本成功完成,该单元就不再活动:

initrd:~# systemctl status ask_network_config
● ask_network_config.service - Ask for network config
     Loaded: loaded (/lib/systemd/system/ask_network_config.service; enabled-runtime; vendor preset: >
     Active: inactive (dead) since Tue 2022-04-12 07:27:03 UTC; 1min 4s ago
    Process: 140 ExecStart=/usr/bin/ask_network_config (code=exited, status=0/SUCCESS)
   Main PID: 140 (code=exited, status=0/SUCCESS)

Apr 12 07:21:55 localhost systemd[1]: Starting Ask for network config...
Apr 12 07:21:58 localhost imager[175]: Asking for network config.
Apr 12 07:26:56 localhost imager[194]: Configuring network
Apr 12 07:26:56 localhost systemd[1]: Finished Ask for network config.
Apr 12 07:27:03 localhost systemd[1]: ask_network_config.service: Succeeded.
Apr 12 07:27:03 localhost systemd[1]: Stopped Ask for network config.
initrd:~# Shared connection to 192.168.76.5 closed.

如何解决此问题,以便在成功完成后显示为活动状态?

相关内容