2009-12-27

カスタムMSS2のSambaを「ごみ箱」対応にする

カスタムファームウェアを入れたNAS「Maxtor Shared Storage II」(MSS2)にSambaを入れてみます。
参考過去記事:
 MSS2にカスタムファームウェアを入れる
 カスタムMSS2のパッケージ管理システム(optwareとipkg)について

Sambaは標準で入ってるのに、なぜ自分で導入するの?

純正MSS2にもSambaは入っています。というかNASですから、Sambaこそがメイン機能です。
じゃあどうしてわざわざ改めてSambaを入れるかと言うと…、デフォルトで入ってるSambaには「ごみ箱」(recycle bin)機能がないのです。
ごみ箱機能は――削除操作したファイルをいきなりHDDから消してしまわずに、いったん一時的な場所に格納しておく…という説明をするまでもないポピュラーなものですが――PC上ではローカルなHDDにしか使えません。
そのため、NASでごみ箱を使うには、PC側ではなくNAS側で仕組みを用意する必要があるのです。

ipkgを使ってoptwareのSambaをインストール

ではSambaをインストールします。
# /opt/bin/ipkg list | grep samba
samba - 3.2.15-1 - Samba suite provides file and print services to SMB/CIFS clients.
samba2 - 2.2.12-1 - Lightweight Samba suite provides file and print services to SMB/CIFS clients.
samba3-dev - 3.2.15-1 - development files for samba3
samba3-swat - 3.2.15-1 - the Samba Web Admin Tool for samba3

現在の安定版が3.4系で、その前の安定版が3.3系なので、optwareで入手できる3.2系は「前の前の安定版」ということになりますが、ごみ箱を使うぶんには差し支えありません。

# /opt/bin/ipkg install samba
Installing samba (3.2.15-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/samba_3.2.15-1_arm.ipk
package samba suggests installing cups
Installing popt (1.15-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/popt_1.15-1_arm.ipk
Installing readline (6.0-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/readline_6.0-1_arm.ipk
Installing openldap-libs (2.3.43-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/openldap-libs_2.3.43-1_arm.ipk
Installing openssl (0.9.7m-5) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/openssl_0.9.7m-5_arm.ipk
Installing libdb (4.2.52-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/libdb_4.2.52-3_arm.ipk
Installing gdbm (1.8.3-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/gdbm_1.8.3-2_arm.ipk
Installing cyrus-sasl-libs (2.1.23-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable/cyrus-sasl-libs_2.1.23-1_arm.ipk
Configuring cyrus-sasl-libs
Configuring gdbm
Configuring libdb
Configuring openldap-libs
Configuring openssl
Configuring popt
Configuring readline
Configuring samba
The original samba version 2 config (/etc/samba/smb.conf) is no longer
working with this version of samba.
Please create a new samba version 3 config (/opt/etc/samba/smb.conf).
After verify your smb.conf file, modify and execute /opt/etc/init.d/S08samba
to activate the samba version 3.
Successfully terminated.

Sambaパッケージだけでなく、依存しているパッケージもいくつか自動でインストールされたようです。

これでごみ箱が使えるようになったかというと、最後のメッセージを見るに、いま入れたSambaは自動的には使用可能にならない模様。
指示に従い、/opt/etc/samba/smb.conf を作成してから /opt/etc/init.d/S08samba を書き換えることにします。

smb.confの設定

smb.confを一から作るのも大変なので、デフォルトのsmb.confを流用します。
/etc になくて探しましたが、/usr/lib で発見。
(ちなみにSambaが使うディレクトリは、smbd -b としてビルドオプションを表示させれば分かります)

元のSambaのバージョンは 3.0.10 だったので(smbd -Vで確認できます)、設定ファイルの互換性的には問題ないでしょうということで、ごみ箱に関する部分だけ書き加えます。

ユーザーの共有リソースのセクションに、下記赤字部を追加しました。
[***]
comment = ***
path = /share/***
invalid users =
read list =
write list = "***"
printable = no
vfs objects = recycle
recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes

init.d/S08sambaの編集

次に /opt/etc/init.d/S08samba を編集します。
とりあえず中身を見てみると、
#!/bin/sh

# set samba_active=1 to activate samba
samba_active=0

[ 1 = $samba_active ] || exit 0

if [ -n "`pidof smbd`" ] ; then
    echo "Stopping smbd:"
    killall smbd
fi

if [ -n "`pidof nmbd`" ] ; then
    echo "Stopping nmbd:"
    killall nmbd
fi

sleep 2

echo "Starting nmbd:"
/opt/sbin/nmbd -D
echo "Starting smbd:"
/opt/sbin/smbd -D

なるほど、このままではSambaが起動しないようになっています。
「samba_active=1」と書き換えます。他は触る必要はなさそう。

デフォルトのSambaを無効化

新しいSambaを起動する前に、古いSambaを止めましょう。
Web管理画面を Advanced Features > Advanced Configuration >Services と進み、nmbd と smbd のチェックボックスをoffにします。

Sambaの認証ファイルをコピー

このままでも新しいSambaは動きますが、共有フォルダにアクセスしようとしても認証が通りません。パスワードが格納されているファイルもコピーします。
# cp /usr/private/secrets.tdb /usr/private/smbpasswd /opt/etc/samba

新しいSambaを起動

# /opt/etc/init.d/S08samba

これでごみ箱も使えるようになったはずです。ファイルを削除すると、.recycleフォルダの中に出現するはず。

0 件のコメント:

コメントを投稿

同ラベルリンク