Chinaunix首页 | 论坛 | 博客
  • 博客访问: 403277
  • 博文数量: 49
  • 博客积分: 6020
  • 博客等级: 准将
  • 技术积分: 520
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-18 21:36
文章分类

全部博文(49)

文章存档

2008年(14)

2007年(4)

2006年(31)

我的朋友

分类: LINUX

2008-04-29 19:33:53

    上星期5出差回来的,周末休息了2天,开始上班了,又开始忙了,所以没多少时间写东西了,今天有空又写一点,那就加紧不废话了
   

if [ "$(get_KV)" -ge "$(KV_to_int '2.5.68')" ]
    then
        have_devpts="$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)"

        if [ "${have_devpts}" = "yes" ]
        then
            if [ ! -d /dev/pts ] && \
             [ "${devfs}" = "yes" -o "${udev}" = "yes" ]
            then
                # Make sure we have /dev/pts

                mkdir -p /dev/pts &>/dev/null || \
                    ewarn "Could not create /dev/pts!"
            fi

            if [[ -d /dev/pts ]] ; then
                ebegin "Mounting devpts at /dev/pts"
                if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
                    mntcmd=$(get_mount_fstab /dev/pts)
                else
                    unset mntcmd
                fi
                try mount -n ${mntcmd:--t devpts devpts /dev/pts -o gid=5,mode=0620,noexec,nosuid}
                eend $?
            fi
        fi
    fi

    前面我们分析过,get_KV和KV_to_int,这个判断调试其实就如果但前的内核版本比2.5.68大或者等于的话,就需要执行下面的代码。

have_devpts="$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)"

if [ "${have_devpts}" = "yes" ]

    判断/proc/filesystems下面是否有devpts,如果有,那么执行下面的代码,cat /proc/filesystems,确实有devpts,那么就执行

nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev cpuset
nodev sockfs
nodev pipefs
nodev anon_inodefs
nodev futexfs
nodev tmpfs
nodev inotifyfs
nodev configfs
nodev devpts
        reiserfs
        ext3
        ext4dev
        ext2
        squashfs
nodev ramfs
        vfat
        iso9660
        udf
        xfs
        ocfs2
nodev ocfs2_dlmfs
        gfs2
        gfs2meta
nodev mqueue
nodev usbfs
        jfs
nodev rpc_pipefs
nodev nfs

    在下面的判断,我是不知道开机的时候有没有/dev/pts这个目录,开机后是有,那么根据判断的话,是执行下面的if语句,在原来的分析里面也知道,RC_USE_FSTAB这个值为no,所以最后会执行

mount -n -t devpts devpts /dev/pts -o uid=5,mode=0620,noexec,nosuid

   在接下去的话,就开始执行/etc/init.d/里面的脚本了,先介绍一下一个大功能函数

    start_critical_service() {
        local service="$1"
        (
        local retval=
        local myservice="${service}"

        profiling name "/etc/init.d/${service} start"
        splash "svc_start" "${service}"
        
        source "/etc/init.d/${service}"
        retval=$?
        if [[ ${retval} -ne 0 ]] ; then
            eerror "Failed to source /etc/init.d/${service}"
            return "${retval}"
        fi

        local conf="$(add_suffix /etc/conf.d/${service})"
        [[ -e ${conf} ]] && source "${conf}"
        conf="$(add_suffix /etc/rc.conf)"
        [[ -e ${conf} ]] && source "${conf}"

        start
        )
        
        if [[ $? == "0" ]] ; then
            splash "svc_started" "${service}" "0"
            return 0
        fi

        eerror "Failed to start /etc/init.d/${service}"
        splash "critical" &>/dev/null &
        echo
        eerror "One or more critical startup scripts failed to start!"
        eerror "Please correct this, and reboot ..."
        echo; echo
        sulogin ${CONSOLE}
        einfo "Unmounting filesystems"
        /bin/mount -a -o remount,ro &>/dev/null
        einfo "Rebooting"
        /sbin/reboot -f
    }

    看函数名字就很清楚start_critical_service,开始关键的服务,那肯定很重要咯,根据传进来的第一个参数,进行判断,然后执行

source "/etc/init.d/${service}"

    在接下去根据/etc/conf.d下面是否有对应文件和/etc/rc.d,如果存在就source

[[ -e ${conf} ]] && source "${conf}"

[[ -e ${conf} ]] && source "${conf}"

   马上就要进入/etc/init.d/了,有写激动了,嘿嘿,那就休息休息,不要着急,To Be Continue!!!!!!!!!!!!!!!!!!!!!!!!!!!!

阅读(2239) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~