根據行政部需求,需要把samba中共享的文件夾名稱由原來的英文 "share" 改成中文的 "行政部" 幾個字.
samba配置的是Win2003域控驗證, 原來在samba中設置的編碼爲 cp936, 在samba的共享的文件夾中均能夠正常顯示中文。
- # 20080816 ritto.
- [global]
- workgroup = SBZ
- server string = mis
- password server = 192.168.5.10
- encrypt passwords = yes
- realm = SBZ.COM
- security = ads
- idmap uid = 16777216-33554431
- idmap gid = 16777216-33554431
- winbind separator = /
- template homedir = /home/%D/%U
- template shell = /bin/bash
- #template shell = /sbin/nologin
- winbind use default domain = true
- winbind offline logon = true
- winbind enum users = yes
- winbind enum groups = yes
- smb passwd file = /etc/samba/smbpasswd
- nt acl support = yes
- passwd program = /usr/bin/passwd %u
- passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successful
- disable spoolss = yes
- log file = /var/log/samba/%m.log
- dos charset = cp936
- unix charset = cp936
- display charset = cp936
- wins server = 192.168.5.10
- [share]
- comment = share
- inherit acls = yes
- path = /data0/share
- force user = share
- force group = share
- force create mode = 0664
- force directory mode = 0775
- public = no
- valid users = sbz.com/ritto.zhao,sbz.com/eva.huang
- write list = sbz.com/ritto.zhao,sbz.com/eva.huang
在上面的 [share] 直接改成 [行政部]之後,發現 samba不能啓動了,查來查去才發現是samba不認中文,最後將samba中指定的編碼改成utf8, 纔可以正常啓動.
更改的部分如下:
- dos charset = UTF8
- unix charset = UTF8
- display charset = UTF8
- ......
- [行政部]
- comment = 行政部
- inherit acls = yes
- path = /data0/share
- force user = share
- force group = share
- force create mode = 0664
- force directory mode = 0775
- public = no
- valid users = sbz.com/ritto.zhao,sbz.com/eva.huang
- write list = sbz.com/ritto.zhao,sbzcom/eva.huang
改好之後,samba支持中文了,也可以正常啓動了。
可是,之前定義爲cp936時,共享文件夾中的一些帶中文的文件及文件夾全部亂碼了,不能顯示顯示了。
於是,需要將之前的文件編碼由cp936改成utf8了.
腳本如下(網上搜集的,很好用):
- #/bin/sh
- var=0
- echo $var
- execing () {
- local dir=$1
- var=`expr $var + 1`
- echo $var $dir
- shift
- while [ "$1" ]
- do
- echo $dir/$1
- if [ -d "$dir/$1" ]
- then
- execing $dir/$1 `ls $dir/$1`
- fi
- convmv --notest -f cp936 -t utf8 $dir/$1
- shift
- done
- }
- execing $1 `ls $1`
轉換正常,文件又恢復成正常的中文了,哈哈