´ÙÀ½ ÀÌÀü Â÷·Ê

8. ½Ã½ºÅÛ ºÎÆ® ½ºÅ©¸³Æ®ÀÇ »ý¼º

ÀÌ ºÎÆ® ½ºÅ©¸³Æ®µéÀº ½Ã½ºÅÛÀÌ ºÎÆÃµÉ ¶§ ½ÃÀ۵ȴÙ. ÀÌ ½ºÅ©¸³Æ®µéÀº ·çÆ® ÆÄÀÏ ½Ã½ºÅÛÀ» ÀÐ°í ¾²±â ¸ðµå·Î ¸¶¿îÆ®ÇÏ°í, ½º¿ÒÀ» È°¼ºÈ­ÇÏ¸ç ¸î¸î ½Ã½ºÅÛ ¼³Á¤À» ÇÏ°í ¿ì¸® ½Ã½ºÅÛÀÌ ÇÊ¿äÇÑ ´Ù¾çÇÑ µ¥¸óµéÀ» ½ÃÀÛÇÏ´Â ¿ªÇÒÀ» ÇÑ´Ù.

8.1 µð·ºÅ丮¿Í ¸¶½ºÅÍ ÆÄÀÏÀÇ Áغñ

ÀÌ Àå¿¡¼­ ¿©·¯ºÐÀº ´Ù½Ã Sysvinit ÆÐÅ°Áö°¡ ÇÊ¿äÇÏ´Ù.

   cd /etc
   mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d init.d rcS.d
 

   #!/bin/sh
   # Begin /etc/init.d/rcS
   
   runlevel=S
   prevlevel=N
   umask 022
   export runlevel prevlevel
 
   trap ":" INT QUIT TSTP
   
   for i in /etc/rcS.d/S??*
   do
      [ ! -f  "$i" ] && continue;
      $i start       
   done
 
   # End /etc/init.d/rcS
 

8.2 reboot ½ºÅ©¸³Æ® ¸¸µé±â

   #!/bin/sh
   # Begin /etc/init.d/reboot
  
   echo -n "System reboot in progress..."
   
   /sbin/reboot -d -f -i
 
   # End /etc/init.d/reboot
 

8.3 halt ½ºÅ©¸³Æ® »ý¼º

   #!/bin/sh
   # Begin /etc/init.d/halt
 
   /sbin/halt -d -f -i -p
 
   # End /etc/init.d/halt
 

8.4 mountfs ½ºÅ©¸³Æ®ÀÇ »ý¼º

#!/bin/sh
# Begin /etc/init.d/mountfs
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
echo -n "Remounting root file system in read-write mode..."
/bin/mount -n -o remount,rw /
check_status
 
> /etc/mtab
/bin/mount -f -o remount,rw /
 
echo -n "Mounting proc file system..."
/bin/mount proc
check_status
 
# End /etc/init.d/mountfs
 

8.5 umountfs ½ºÅ©¸³Æ®ÀÇ »ý¼º

#!/bin/sh
# Begin /etc/init.d/umountfs
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
  
echo "Deactivating swap..."
/bin/swapoff -av
check_status
 
echo -n "Unmounting file systems..."
/bin/umount -a -r 
check_status
 
# End /etc/init.d/umountfs
 

8.6 sendsignals ½ºÅ©¸³Æ®ÀÇ »ý¼º

#!/bin/sh
# Begin /etc/init.d/sendsignals
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
echo -n "Sending all processes the TERM signal..."
/sbin/killall5 -15
check_status
 
echo -n "Sending all processes the KILL signal..."
/sbin/killall5 -9
check_status
 

8.7 checkroot ºÎÆ® ½ºÅ©¸³Æ®ÀÇ »ý¼º

#!/bin/sh
# Begin /etc/init.d/checkroot
 
echo "Activating swap..."
/sbin/swapon -av
 
if [ -f /fastboot ]
then
  echo "Fast boot, no file system check"
else
  /bin/mount -n -o remount,ro /
  if [ $? = 0 ]
  then
    if [ -f /forcecheck ]
    then
      force="-f"
    else
      force=""
    fi
 
    echo "Checking root file system..."
    /sbin/fsck $force -a /
     
    if [ $? -gt 1 ]
    then
      echo
      echo "fsck failed. Please repair your file system manually by"
      echo "running fsck without the -a option"
      
      echo "Please note that the file system is currently mounted in"
      echo "read-only mode."
      echo
      echo "I will start sulogin now. CTRL+D will reboot your system."
      /sbin/sulogin
      /reboot -f
    fi
  else
    echo "Cannot check root file system because it is not mounted in"
    echo "read-only mode."
  fi
fi
 
# End /etc/init.d/checkroot
 

8.8 Sysklogd ºÎÆ® ½ºÅ©¸³Æ®ÀÇ »ý¼º

#!/bin/sh
# Begin /etc/init.d/sysklogd
 
check_status()
{
  if [ $? = 0 ]
  then
    echo "OK"
  else
    echo "FAILED"
  fi
}
 
case "$1" in
  start)
    echo -n "Starting system log daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/syslogd -- -m 0
    check_status
 
    echo -n "Starting kernel log daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/klogd
    check_status
    ;;
 
  stop)
    echo -n "Stopping kernel log daemon..."
    start-stop-daemon -K -q -o -p  /var/run/klogd.pid
    check_status
 
    echo -n "Stopping system log daemon..."
    start-stop-daemon -K -q -o -p /var/run/syslogd.pid
    check_status
    ;;
 
  reload)
    echo -n "Reloading system load daemon configuration file..."
    start-stop-daemon -K -q -o -s 1 -p /var/run/syslogd.pid
    check_status
    ;;
 
  restart)
    echo -n "Stopping kernel log daemon..."
    start-stop-daemon -K -q -o -p /var/run/klogd.pid
    check_status
 
    echo -n "Stopping system log daemon..."
    start-stop-daemon -K -q -o -p /var/run/syslogd.pid
    check_status
 
    sleep 1
 
    echo -n "Starting system log daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/syslogd -- -m 0
    check_status
 
    echo -n "Starting kernel log daemon..."
    start-stop-daemon -S -q -o -x /usr/sbin/klogd
    check_status
    ;;
 
  *)
    echo "Usage: $0 {start|stop|reload|restart}"
    exit 1
    ;;
esac
 
# End /etc/init.d/sysklogd
 

8.9 ½Éº¼¸¯ ¸µÅ©¿Í ±ÇÇÑ ¼³Á¤

chmod 755 rcS reboot halt mountfs umountfs sendsignals checkroot sysklogd
cd ../rc0.d
ln -s ../init.d/sysklogd K90sysklogd
ln -s ../init.d/sendsignals S80sendsignals
ln -s ../init.d/umountfs S90umountfs
ln -s ../init.d/halt S99halt
cd ../rc6.d
ln -s ../init.d/sysklogd K90sysklogd
ln -s ../init.d/sendsignals S80sendsignals
ln -s ../init.d/umountfs S90umountfs
ln -s ../init.d/reboot S99reboot
cd ../rcS.d
ln -s ../init.d/checkroot S05checkroot
ln -s ../init.d/mountfs S10mountfs
cd /etc/rc2.d
ln -s ../init.d/sysklogd S03sysklogd
 

8.10 /etc/fstab ÆÄÀÏÀÇ »ý¼º

   /dev/<LFS-partition designation> / ext2 defaults 0 1
   /dev/<swap-partition designation> none swap sw 0 0
   proc /proc proc defaults 0 0
 

´ÙÀ½ ÀÌÀü Â÷·Ê