当接口启动时,位于 /etc/network/if-up.d 中的每个脚本都会运行吗?

当接口启动时,位于 /etc/network/if-up.d 中的每个脚本都会运行吗?

当网络接口启动时,/etc/network/if-up.d 中的所有脚本都会运行吗?

如果是,那么接口文件中的发布命令是什么?

答案1

是的,通常任何标记为可执行并放在该文件夹中的脚本都会运行。由于使用了 run-parts,因此文件确实仅限于一组特定的名称。

与使用 的作用post-up相同up。将脚本放在 if-up.d 中与简单地使用指向其他地方的脚本或命令相同post-up。通常,当您只需要为单个接口运行单个命令时,您会使用 up|post-up。当您有更复杂的东西时,您可以创建一个脚本。

人机界面

...
up command

post-up command
      Run  command  after  bringing the interface up.  If this command
      fails then ifup aborts, refraining from marking the interface as
      configured  (even  though it has really been configured), prints
      an error message, and exits with status 0.   This  behavior  may
      change in the future.
...
There  exists  for  each  of  the  above  mentioned options a directory
/etc/network/if-<option>.d/ the scripts in which are run (with no argu-
ments) using run-parts(8) after the option itself has been processed.

人运行部件

run-parts  runs  all  the  executable  files  named  within constraints
described below,

If  the  --lsbsysinit  option  is not given then the names must consist
entirely of upper and lower  case  letters,  digits,  underscores,  and
hyphens.
...
Files are run in the lexical sort  order  of  their  names  unless  the
--reverse  option  is given, in which case they are run in the opposite
order.

相关内容