Next Previous Contents

4. 執行這兩個 daemon

這兩個 daemon 是 /usr/sbin/smbd 和 /usr/sbin/nmbd.

你可以執行 Samba daemon 從 inetd 或當成單獨的程序. 如果你正設定一個永久檔案伺服器,你應該從 inetd 來執行,所以如果他們死掉,那將重新開始.如果你只是偶爾想要使用 SMB 伺服器,或者用系統管理來輔助,當你需要時,你可以藉由使用 /etc/rc.d/init.d script,或甚至直接手動的.

要從 inetd 來執行 daemon , 請放以下幾行在 inetd 組態檔, /etc/inetd.conf:


    # SAMBA NetBIOS services (for PC file and print sharing)
    netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd
    netbios-ns dgram udp wait root /usr/sbin/nmbd nmbd

然後下指令以便重新啟動 inetd daemon :


    kill -HUP 1

要從系統啟動的 script 來執行 daemon, 請把以下的 script 置於一個叫做 /etc/rc.d/init.d/smb 檔, 而且 symbolically link 到註釋{comments}所說明的檔案:


    #!/bin/sh

    #
    # /etc/rc.d/init.d/smb - starts and stops SMB services.
    #
    # The following files should be synbolic links to this file:
    # symlinks: /etc/rc.d/rc1.d/K35smb  (Kills SMB services on shutdown)
    #           /etc/rc.d/rc3.d/S91smb  (Starts SMB services in multiuser mode)
    #           /etc/rc.d/rc6.d/K35smb  (Kills SMB services on reboot)
    #

    # Source function library.
    . /etc/rc.d/init.d/functions

    # Source networking configuration.
    . /etc/sysconfig/network

    # Check that networking is up.
    [ ${NETWORKING} = "no" ] && exit 0

    # See how we were called.
    case "$1" in
      start)
        echo -n "Starting SMB services: "
        daemon smbd -D  
        daemon nmbd -D 
        echo
        touch /var/lock/subsys/smb
        ;;
      stop)
        echo -n "Shutting down SMB services: "
        killproc smbd
        killproc nmbd
        rm -f /var/lock/subsys/smb
        echo ""
        ;;
      *)
        echo "Usage: smb {start|stop}"
        exit 1
    esac


Next Previous Contents