• Ubuntuに関連したハード、ソフトの備忘録サイトです

コンパイル版Samba4の起動スクリプトについて

  • 2015年12月14日

Ubuntuの様子がおかしくなり、バックアップを取ってクリーンインストールする羽目に陥りました。完全には取れませんでした。(^_^;)。そこで、適当に起動していたコンパイル版Samba4のかなり正式な起動スクリプトを下記にまとめてみました。

#! /bin/bash
#
# samba4       Bring up/down samba4 service 
#
# chkconfig: - 90 10
# description: Activates/Deactivates all samba4 interfaces configured to \
#              start at boot time.
#
### BEGIN INIT INFO
# Provides: 
# Should-Start: 
# Short-Description: Bring up/down samba4
# Description: Bring up/down samba4
### END INIT INFO
# Source function library.
. /etc/init.d/functions

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

CWD=$(pwd)
prog="samba4"

start() {
    # Attach irda device 
    echo -n $"Starting $prog: "
    /usr/local/samba/sbin/samba
    sleep 2
    if ps ax | grep -v "grep" | grep -q /samba/sbin/samba ; then success $"samba4 startup"; else failure $"samba4 startup"; fi
    echo
}
stop() {
    # Stop service.
    echo -n $"Shutting down $prog: "
    killall samba
    sleep 2
    if ps ax | grep -v "grep" | grep -q /samba/sbin/samba ; then failure $"samba4 shutdown"; else success $"samba4 shutdown"; fi
    echo
}

status() {
    /usr/local/samba/sbin/samba --show-build
}

# See how we were called.
case "$1" in
start)
    start
      ;;
stop)
    stop
      ;;
status)
    status irattach
    ;;
restart|reload)
    stop
    start
    ;;
*)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
esac

exit 0

大体はこんな感じだと思います。それで、起動時にSamba4を起動する方法は、下記参考にされて下さい。

$ sudo systemctl enable samba4

Windows 7さんたちをドメインに登録するのに、「RPCサーバーが利用できません」とのエラーが出て、登録できない状態が続きましたが、上記のスクリプトでSambaを起動させると、ドメインに登録できたような・・・。また、Active Directoy 対応のSamba4の本格的な解説書が出るのを待つしかないですね。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA