对于每个新服务,我必须编辑并插入一行来打开一个端口.这导致在不同的机器上有许多不同版本的init.d脚本.
是否可以自动包含让我们说/etc/iptables/include.d/中的所有文件?
目标是/etc/init.d/iptables的启动函数中只应该有一行代码
include /etc/iptables/include.d/*
在/etc/iptables/include.d/中添加了一个额外的文件后,我只想说
/etc/init.d/iptables restart
编辑:正如Saurabh所指出的那样,当命令需要某个命令时,这会导致问题.高级设置可能有不同的目录,如:
/etc/iptables/include01.d//etc/iptables/include02.d//etc/iptables/include03.d/
包括他们像这样:
include /etc/iptables/include01.d/* ... maybe some code goes here in the main file... include /etc/iptables/include02.d/* include /etc/iptables/include03.d/*解决方法 将以下行添加到init.d脚本中.
run-parts --report /etc/iptables/include.d
它将作为shell脚本运行目录中的所有内容(需要可执行).
如果您只想执行以.port结尾的文件,您可以使用某些东西
喜欢:
run-parts --regex '\.port$' /etc/iptables/include.d/
如果您想确保订单正确,可以为文件命名:
10_web.port20_ssh.portetc..总结
以上是内存溢出为你收集整理的linux – 如何在shell脚本中包含目录中的所有文件(在本例中为/etc/init.d/iptables)全部内容,希望文章能够帮你解决linux – 如何在shell脚本中包含目录中的所有文件(在本例中为/etc/init.d/iptables)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)