スクリプト


起動スクリプト

#!/bin/sh
#
# chkconfig: - 91 35
# description: Starts and stops the Samba smbd and nmbd daemons \
#              used to provide SMB network services.
#
# pidfile: /usr/local/samba/var/locks/smbd.pid
# pidfile: /usr/local/samba/var/locks/nmbd.pid
# config:  /usr/local/samba/lib/smb.conf


# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# Avoid using root's TMPDIR
unset TMPDIR

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

if [ -f /etc/sysconfig/samba ]; then
   . /etc/sysconfig/samba
fi

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

# Check that smb.conf exists.
[ -f /usr/local/samba/lib/smb.conf ] || exit 0

# Check that we can write to it... so non-root users stop here
[ -w /usr/local/samba/lib/smb.conf ] || exit 0

# Check whether "netbios disabled" is true
ISNETBIOSDISABLED=$(testparm -s 2>/dev/null | \
        sed -n '/\[global\]/,/^$/p' | \
        grep "disable netbios = Yes" | \
        awk 'BEGIN{FS=" = "}{print $2}')


RETVAL=0


start() {
        KIND="SMB"
        echo -n $"Starting $KIND services: "
        daemon /usr/local/samba/sbin/smbd $SMBDOPTIONS
        RETVAL=$?
        echo
        KIND="NMB"
        if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
                echo -n $"Starting $KIND services: "
                daemon /usr/local/samba/sbin/nmbd $NMBDOPTIONS
                RETVAL2=$?
                echo
                [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
                        RETVAL=1
        else
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
                        RETVAL=1
        fi
        return $RETVAL
}

stop() {
        KIND="SMB"
        echo -n $"Shutting down $KIND services: "
        killproc smbd
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /usr/local/samba/var/run/smbd.pid
        echo
        KIND="NMB"
        if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
                echo -n $"Shutting down $KIND services: "
                killproc nmbd
                RETVAL2=$?
                [ $RETVAL2 -eq 0 ] && rm -f /usr/local/samba/var/run/nmbd.pid
                [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb
                echo ""
        else
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb
                echo ""
        fi
        return $RETVAL
}

restart() {
        stop
        start
}

reload() {
        echo -n $"Reloading smb.conf file: "
        killproc smbd -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

rhstatus() {
        status smbd
        status nmbd
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  reload)
        reload
        ;;
  status)
        rhstatus
        ;;
  condrestart)
        [ -f /var/lock/subsys/smb ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
        exit 1
esac

exit $?

logrotateスクリプト

/usr/local/samba/var/log* {
    notifempty
    missingok
    sharedscripts
    copytruncate
    postrotate
        /bin/kill -HUP `cat /usr/local/samba/var/locks/smbd.pid \
                            /usr/local/samba/var/locks/nmbd.pid \
                            /usr/local/samba/var/locks/winbindd.pid \
                            2> /dev/null` 2> /dev/null || true
    endscript
}

トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2010-06-10 (木) 22:41:42 (2809d)