創(chuàng)建BSD啟動(dòng)腳本/etc/rc.d/rc.sysinit
創(chuàng)建BSD啟動(dòng)腳本/etc/rc.d/rc.sysinit
創(chuàng)建BSD啟動(dòng)腳本/etc/rc.d/rc.sysinit
/etc/HOSTNAME一定要?jiǎng)?chuàng)建,下面腳本中要用,要不然下面會(huì)出錯(cuò)。
-----------------------------/etc/rc.d/rc.sysinit----------------------------
#!/bin/sh
#以只讀方式mount根系統(tǒng)
echo "Mounting root device read-only..."
/bin/mount -n -o remount,ro /
# 掛載swap交換區(qū)
echo "Initializing swap partitions..."
/sbin/swapon -a
# $?為命令返回值,1為錯(cuò)誤。fsck檢查文件系統(tǒng)錯(cuò)誤則重啟。
/sbin/fsck -A -a -C
if [ $? -gt 1 ]; then
echo
echo "ERROR:"
echo "Your filesystem has been severely damaged. You can probably correct this"
echo "problem by running e2fsck manually (eg. with the -v and -y options). After"
echo "you logout, the system will reboot."
echo
PS1="(Repair filesystem)# "
export PS1
/sbin/sulogin
/bin/umount -a -r
/sbin/reboot -f
fi
# 以可讀寫方式重新mount文件系統(tǒng)。
echo "Remounting root device read-write..."
/bin/mount -n -v -o remount,rw /
echo "" >/etc/mtab
/bin/mount -f -o remount,rw /
# 掛載其它本地文件系統(tǒng)。
echo "Mounting other local filesystems..."
/bin/mount -a -v -tnonfs
# 設(shè)置主機(jī)名和域名。
echo "Setting up hostname..."
/bin/hostname `cat /etc/HOSTNAME |cut -d . -f1`
/bin/domainname `cat /etc/HOSTNAME |cut -d . -f2-`
# 隨機(jī)數(shù)設(shè)備
if [ -f "/etc/random-seed" ]; then
echo "Initializing random number generator..."
/bin/cat /etc/random-seed >/dev/urandom
rm -f /etc/random-seed
fi
echo "Loading keymap..."
/usr/bin/loadkeys -d
#設(shè)置系統(tǒng)時(shí)間
echo "Setting system time from hardware clock..."
/sbin/hwclock --hctosys --utc
#開啟系統(tǒng)和內(nèi)核日志服務(wù)
echo "Starting system and kernel log daemons...."
/usr/sbin/syslogd
/usr/sbin/klogd -c3
### Use modules? If yes, uncomment this:
# echo "Updating module dependencies..."
# /sbin/depmod -a
-------------------------end of /etc/rc.d/rc.sysinit-------------------------