1

I am writing a init.d script that should run commands with certain options if it were being executed at system startup. The same script should run commands with other options if the user was manually executing the script.

For example, in a networking script, if it was being run at the system start up, then certain network interface would not be brought up depending on whether they should be configured ONBOOT. Otherwise, if the user was manually running the networking script (service network start), then all network interfaces would be brought up.

One way i can achieve this is to create a file say "/tmp/.boot" from the parent rc script, which is deleted after all startup scripts are executed. And then in the init script check of the existence of the file /tmp/.boot to determine if the script is being run as part of the startup sequence or not.

I was wondering if there is any existing way of knowing that the system is in its boot up sequence. Could something in /proc/ or elsewhere tell me that the system is in its boot sequence?

Looking forward to your suggestions.

Thanks and Regards ~Sameer

4

1 回答 1

0

首先,/proc 中的状态对于许多脚本来说应该没有太大的不同。运行级别指示您是否处于早期启动阶段(runlevel允许访问它),但在启动中期,启动运行级别 S 仍然存在。

然而,这并不是一件坏事,尝试编写根据运行级别修改行为的脚本是邪恶的。不可调试。您可以简单地尝试其他命令行参数,例如“start-all”而不是“start”。或者你像 Debian 那样分离 RC 脚本。

于 2011-08-01T06:42:09.487 回答