在networking接口通过DHCP接收到地址后,如何确保运行init.d-script?

我只是在debian5系统上安装了couchdb,并在/etc/init.d/couchdb-script中添加了符号链接。 不幸的是,这个脚本在启动之前就被触发了,之后networking接口通过DHCP接收到了couchdb服务器试图绑定的地址 – 这导致实例不可用。

我有点解决这个问题,通过在启动脚本中执行dhclient,但是这只是一个更好的方法…? 在那儿?

是的,有一个更好的方法:把你的couchdb初始化脚本放在/etc/network/if-up.d/这样它会在networkingbuild立后运行。

注意:

  Filenames should consist entirely of upper and lower case letters, digits, underscores, and hyphens. Subdirectories of directory and files with other names will be silently ignored. 

在CentOS上,可能RedHat检查是否有文件/sbin/ifup-local ,如果可用,将执行该文件。

创build它:

 sudo touch /sbin/ifup-local sudo chmod +x /sbin/ifup-local 

然后编辑它来包含你想要的

 #!/bin/sh # your commands or calls to your script here 

希望有所帮助。 我更喜欢Debian的.d目录,但是这似乎是CentOS上最接近的。