Sysvinit调用脚本流程

本文介绍了一个系统的初始化脚本中关键路径和配置项的定义及使用方法。包括虚拟控制台、安全终端列表、初始化脚本位置等核心配置。还展示了如何通过检查特定文件来决定是否执行快速启动,并解释了如何根据不同的运行级别调用相应的处理程序。

Paths.h
#define VT_MASTER "/dev/tty0"  /* Virtual console master */
#define CONSOLE  "/dev/console"  /* Logical system console */
#define SECURETTY "/etc/securetty" /* List of root terminals */
#define SDALLOW  "/etc/shutdown.allow" /* Users allowed to shutdown */
#define INITTAB  "/etc/inittab"  /* Location of inittab */
#define INIT  "/sbin/init"  /* Location of init itself. */
#define NOLOGIN  "/etc/nologin"  /* Stop user logging in. */
#define FASTBOOT "/fastboot"  /* Enable fast boot. */
#define FORCEFSCK "/forcefsck"  /* Force fsck on boot */
#define SDPID  "/var/run/shutdown.pid" /* PID of shutdown program */
#define SHELL  "/bin/sh"  /* Default shell */
#define SULOGIN  "/sbin/sulogin"  /* Sulogin */
#define INITSCRIPT "/etc/initscript" /* Initscript. */
#define PWRSTAT  "/etc/powerstatus" /* COMPAT: SIGPWR reason (OK/BAD) */

main ->init_main ->read_inittab
 strncpy(ch->id, id, sizeof(utproto.ut_id) + 1); /* Hack for different libs. */
 strncpy(ch->process, process, sizeof(ch->process) - 1);


init_main -> start_if_needed ->startup ->spawn
  /* See if there is an "initscript" (except in single user mode). */
  if (access(INITSCRIPT, R_OK) == 0 && runlevel != 'S') {
 /* Build command line using "initscript" */
 args[1] = SHELL;
 args[2] = INITSCRIPT;
 args[3] = ch->id;
 args[4] = ch->rlevel;
 args[5] = "unknown";
 for(f = 0; actions[f].name; f++) {
  if (ch->action == actions[f].act) {
   args[5] = actions[f].name;
   break;
  }
 }
 args[6] = proc;
 args[7] = NULL;

initscript执行inittab中的进程。
# Execute the program.
eval exec "$4"


si::bootwait:/etc/init.d/boot
if test "$container" != "lxc" ; then
    # stat does really only return tmpfs even for devtmpfs
    # but testing both values anyway they change their mind
    DTYPE=$(stat -f -c "%T" /dev 2>/dev/null)
    if test "$DTYPE" != "tmpfs" -a "$DTYPE" != "devtmpfs"; then
        echo -n "Mounting devtmpfs at /dev"
        mount -n -t $DEVTMPFS -o mode=0755 $DEVTMPFS /dev
        rc_status -v -r
    fi

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值