我有一个问题,为什么 ExecStartPre= 在这种情况下具有 FAILURE 状态?因为一切看起来都很好并且正常工作。有人可以解释一下发生了什么事吗?
● networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2018-04-03 05:04:52 MSK; 3min 54s ago
Docs: man:interfaces(5)
Process: 473 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
Process: 467 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=1/FAILURE)
Main PID: 473 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 36864)
CGroup: /system.slice/networking.service
апр 03 05:04:52 debian systemd[1]: Starting Raise network interfaces...
апр 03 05:04:52 debian systemd[1]: Started Raise network interfaces.
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::215:5dff:fe01:303 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:01:XX:XX txqueuelen 1000 (Ethernet)
RX packets 9032 bytes 6039361 (5.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6961 bytes 915411 (893.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 114 bytes 34267 (33.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 114 bytes 34267 (33.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
答案1
这仅仅意味着该命令以状态 1 退出:
/bin/sh -c '[ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle'
如果出现以下情况,它可能会以状态 1 退出:
CONFIGURE_INTERFACES=no
已设置(在 /etc/default/networking 中);或者ifquery --read-environment --list --exclude=lo
返回空;或者udevadm settle
出口 1
前两个本身并不是真正的错误...它们主要是为了帮助决定何时udevadm settle
需要运行...因此,在某种程度上,您可以认为 ExecStartPre 因 status=1 失败可能是“正常的” “以某种方式。
检查我的系统,我发现ifquery
命令返回空输出,因此这很可能是 status=1 的解释。
if
我想 Debian 可以通过使用 an代替,让这个变得更好一点&&
,因为在这种情况下,如果条件不成立,命令不会以状态 1 退出,而是以 0 退出:
/bin/sh -c 'if [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ]; then udevadm settle; fi'