「insserv」

insserv是由update-rc.d使用的低级工具。
insserv通过读取脚本(SysV风格的init脚本)中头部的注释来获取用于创建符号链接的信息,然后使用这些信息创建符号链接。

关于SysV风格的init脚本,查看SysV风格的init脚本

insserv [-v] [-c <config>] [-p <path>] [-d] [-f]
[[/]path/to/init.d/]script …

insserv [-v] [-c <config>] [-p <path>]
[[/]path/to/init.d/]script[,start=<lvl1,lvl2,…>,stop=<lvl1,lvl2,…>]

insserv [-v] [-c <config>] [-p <path>] -r [-d] [-f]
[[/]path/to/init.d/]script …

insserv -h

insserv支持的选项

-v, –verbose

打印但前的执行信息。

-c <config>, –config <config>

指定insserv.conf文件和insserv.conf.d目录的路径。有用的测试。

-o <path>, –override <path>

path中的LSB注释头将覆盖init.d目录中的脚本的现有LSB注释头(默认路径为/etc/insserv/overrides/)。

-p <path>, –path <path>

指定init.d文件夹的路径。

-n, –dryrun

不更新符号链接。

-r, –remove

从所有的runlevel中移出列出的脚本。

-d, –default

使用脚本中定义的默认运行级别。这可能会恢复编辑的runlevel链接方案。

-f, –force

忽略丢失的服务。除此之外,如果在命令行上指定了启动和停止级别,脚本的默认级别将被忽略。

-u <path>, –upstart-job <path>

用于替换已经存在的upstart job路径的路径。默认是/lib/init/upstart-job

-s, –showall

输出运行级别和序列信息。不会更新符号链接。

-h, –help

输出帮助信息。

参数

[[/]path/to/init.d/]

init.d的相对路径或绝对路径。默认为/etc/init.d/。在这种情况下,insserv不会将脚本添加到脚本头中声明的runlevel中,但如果当前启用的脚本的顺序已更改,则可重新命令运行级别(请参阅选项-d)。请注意,如果使用相对路径,则必须从根目录调用insserv。

[[/]path/to/init.d/]script …

必须添加到runlevel的脚本列表。如果使用路径,则应指向引导脚本的绝对或相对位置。 insserv检查这些脚本的存在。对于运行级别,使用脚本中发现的信息。

[[/]path/to/init.d/]script[,start=<lvl1,lvl2,…>]

必须添加到”要开始的指定runlevel“的脚本列表。您可以使用此扩展来覆盖脚本的启动和停止runlevel的默认值。请注意,lvl1,lvl2,…是上面已知的运行级别。扩展名,stop = <lvl1,lvl2,…>也是可以的。

-r [[/]path/to/init.d/]script …

应该从运行级别删除的脚本列表。如果使用路径,则应指向引导脚本的绝对或相对位置。insserv检查这些脚本是否存在。

重写(OVERRIDES)

除了使用扩展名,start = <lvl1,lvl2,…>和stop = <lvl1,lvl2,…>可以使用替代文件替换LSB注释头,或简单提供缺少的LSB注释头。这可以通过在/etc/insserv/overrides/目录中添加init脚本的同名文件来实现,文件的内容是新的LSB注释头。对于没有LSB标头的第三方引导脚本,可以在目录/usr/share/insserv/overrides/中添加相同名称的文件,使其完全符合LSB标准。

upstart job的兼容性

为了让upstart job作为init.d脚本工作,insserv将识别从/init.d/script路径到/lib/init/upstart-job作为upstart job的符号链接,而不是从文件中读取头文件使用参数lsb-header运行脚本来获取脚本头。

退出码

0:服务成功的安装或者移除。
1:服务没有安装或者移出。

注意事项

insserv的通配符*.不接受文件名为以下格式的文件:

*.dpkg*

*.rpm*

*.ba*

*.old

*.new

*.org

*.orig

*.save

*.swp

*.core

*~

除此之外,以$.#%_+-\*[]^:()~开始的文件名也会被忽略。

相关文件

/etc/insserv.conf

用于定义”LSB系统工具“(LSB System Facilities)的insserv的配置文件。

/etc/insserv.conf.d/

用于声明”LSB系统工具“的进一步配置文件

/etc/insserv/overrides/

使用此路径中发现的注释标题替换现有的LSB注释标题

/etc/init.d/

init脚本的存放路径。

/etc/init.d/.depend.boot,
/etc/init.d/.depend.start,
/etc/init.d/.depend.stop

在startpar(8)帮助下,由insserv产生用于引导、启动、停止的类死于make依赖的文件。

BUGS

Boot scripts sometimes lack a LSB comment header. Contact a package maintainer or developer of the software which provides the script to have a LSB comment header added to it.

参考文献

  • man 8 insserv