7月 032017
 

6月29日review涉及的sys-unconfig系统初始化

**关于/usr/sbin/sys-unconfig工具的说明**
**__RHEL 6__**

#!/bin/sh
. /etc/init.d/functions
if [ $# -ne 0 ]; then
    echo $"Usage: sys-unconfig" >&2
    exit 1
fi
touch /.unconfigured
rm -f /etc/udev/rules.d/*-persistent-*.rules
halt

**# vi +556 /etc/rc.d/rc.sysinit**

# Configure machine if necessary.
if [ -f /.unconfigured ]; then
    if [ -x /bin/plymouth ]; then
        /bin/plymouth quit
    fi
    if [ -x /usr/bin/system-config-keyboard ]; then
        /usr/bin/system-config-keyboard
    fi
    if [ -x /usr/bin/passwd ]; then
        /usr/bin/passwd root
    fi
    if [ -x /usr/sbin/system-config-network-tui ]; then
        /usr/sbin/system-config-network-tui
    fi
    if [ -x /usr/sbin/timeconfig ]; then
        /usr/sbin/timeconfig
    fi
    if [ -x /usr/sbin/authconfig-tui ]; then
        /usr/sbin/authconfig-tui --nostart
    fi
    if [ -x /usr/sbin/ntsysv ]; then
        /usr/sbin/ntsysv --level 35
    fi
    # Reread in network configuration data.
    if [ -f /etc/sysconfig/network ]; then
        . /etc/sysconfig/network
        # Reset the hostname.
        action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
    fi
    rm -f /.unconfigured
fi

**__RHEL 7__**

#!/bin/sh
. /etc/init.d/functions
if [ $# -ne 0 ]; then
    echo $"Usage: sys-unconfig" >&2
    exit 1
fi
touch /.unconfigured
rm -f /etc/udev/rules.d/*-persistent-*.rules
poweroff

**检查点/.unconfigured文件**

[root@warriors systemd]# grep -rni \/\.unconfigured /usr/lib/systemd/
/usr/lib/systemd/system/rhel-configure.service:7:ConditionPathExists=/.unconfigured
/usr/lib/systemd/system/rhel-configure.service:11:ExecStopPost=/bin/rm -f /.unconfigured
/usr/lib/systemd/system/initial-setup-reconfiguration.service:11:ConditionPathExists=/.unconfigured

**vi /usr/libexec/initial-setup/reconfiguration-mode-enabled**

#!/bin/bash
echo "The /.unconfigured file has been detected, starting Initial Setup in reconfiguration mode." | systemd-cat -t initial-setup -p 6
/usr/libexec/initial-setup/run-initial-setup
 Posted by at 上午11:3335 views

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)