[packages] samba3: various changes (#10531)

- resolve ipv4 and ipv6 addresses of logical interface names and add them to the interfaces line
	- make charset uci-configurable and default to UTF-8
	- cleanup init script, annotate uci configuration


git-svn-id: svn://svn.openwrt.org/openwrt/packages@29505 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2011-12-12 01:10:26 +00:00
parent de035b83aa
commit 40d7681e6a
4 changed files with 68 additions and 34 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=samba3 PKG_NAME:=samba3
PKG_VERSION:=3.0.37 PKG_VERSION:=3.0.37
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_MD5SUM:=11ed2bfef4090bd5736b194b43f67289 PKG_MD5SUM:=11ed2bfef4090bd5736b194b43f67289

View File

@ -1,16 +1,29 @@
# Base server settings
config samba config samba
option 'name' 'openwrt' ## Override if desired, defaults to hostname
option 'workgroup' 'openwrt' #option 'name' 'OpenWrt'
option 'description' 'openwrt' #option 'workgroup' 'OpenWrt'
option 'homes' '1' #option 'description' 'Samba on OpenWrt'
list 'interface' 'lo'
list 'interface' 'lan' ## Expose user home directories, defaults to off
option 'homes' '1'
## Override character set, default is UTF-8
option 'charset' 'ISO-8859-1'
## Override listen interfaces & addresses,
## defaults to loopback and lan
#list 'interface' 'loopback'
#list 'interface' 'lan'
#list 'interface' '10.0.0.0/255.255.0.0'
#list 'interface' 'eth0'
# Declare a share on /tmp
config sambashare config sambashare
option 'name' 'tmp' option 'name' 'tmp'
option 'path' '/tmp' option 'path' '/tmp'
option 'read_only' 'no' option 'read_only' 'no'
option 'guest_ok' 'no' option 'guest_ok' 'no'
option 'create_mask' '0700' option 'create_mask' '0700'
option 'dir_mask' '0700' option 'dir_mask' '0700'
#option 'users' 'abc' #option 'users' 'abc'

View File

@ -4,42 +4,63 @@
START=60 START=60
smb_header() { smb_header() {
local name
local workgroup
local description
local homes
local interface local interface
config_get interface $1 interface "loopback lan"
config_get name $1 name
config_get workgroup $1 workgroup
config_get description $1 description
config_get homes $1 homes
config_get interface $1 interface "lan"
# resolve interfaces # resolve interfaces
local interfaces=$( local interfaces=$(
include /lib/network include /lib/network
scan_interfaces scan_interfaces
local net ifname; for net in $interface; do
config_get ifname "$net" ifname "$net" local net
echo -n "$ifname " for net in $interface; do
local ifname
config_get ifname "$net" ifname
[ -n "$ifname" ] && {
local ipaddr netmask
config_get ipaddr "$net" ipaddr
config_get netmask "$net" netmask
[ -n "$ipaddr" ] && echo -n "$ipaddr/${netmask:-255.255.255.255} "
local ip6addr
config_get ip6addr "$net" ip6addr
[ -n "$ip6addr" ] && echo -n "$ip6addr "
}
echo -n "${ifname:-$net} "
done done
) )
[ -z "$name" ] && name=openwrt local name workgroup description charset
[ -z "$workgroup" ] && workgroup=openwrt local hostname="$(uci_get system.@system[0].hostname)"
[ -z "$description" ] && description=openwrt
config_get name $1 name "${hostname:-OpenWrt}"
config_get workgroup $1 workgroup "${hostname:-OpenWrt}"
config_get description $1 description "Samba on ${hostname:-OpenWrt}"
config_get charset $1 charset "UTF-8"
mkdir -p /var/etc mkdir -p /var/etc
cp /etc/samba/smb.conf.template /var/etc/smb.conf sed -e "s#|NAME|#$name#g" \
[ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf -e "s#|WORKGROUP|#$workgroup#g" \
sed -i "s/|NAME|/$name/g" /var/etc/smb.conf -e "s#|DESCRIPTION|#$description#g" \
sed -i "s/|WORKGROUP|/$workgroup/g" /var/etc/smb.conf -e "s#|INTERFACES|#$interfaces#g" \
sed -i "s/|DESCRIPTION|/$description/g" /var/etc/smb.conf -e "s#|CHARSET|#$charset#g" \
sed -i "s/|INTERFACES|/$interfaces/g" /var/etc/smb.conf /etc/samba/smb.conf.template > /var/etc/smb.conf
[ "$homes" == "1" ] && {
echo -e "\n[homes]\n\tcomment = Home Directories\n\tbrowseable = no\n\tread only = no\n\tcreate mode = 0750" >> /var/etc/smb.conf local homes
config_get_bool homes $1 homes 0
[ $homes -gt 0 ] && {
cat <<EOT >> /var/etc/smb.conf
[homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750
EOT
} }
[ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
} }
smb_add_share() { smb_add_share() {

View File

@ -7,7 +7,7 @@
passdb backend = smbpasswd passdb backend = smbpasswd
obey pam restrictions = yes obey pam restrictions = yes
socket options = TCP_NODELAY socket options = TCP_NODELAY
unix charset = ISO-8859-1 unix charset = |CHARSET|
preferred master = yes preferred master = yes
os level = 20 os level = 20
security = share security = share