[packages] samba3: various changes (#10531)
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Dec 2011 01:10:26 +0000 (01:10 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Dec 2011 01:10:26 +0000 (01:10 +0000)
- 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

SVN-Revision: 29505

net/samba3/Makefile
net/samba3/files/samba.config
net/samba3/files/samba.init
net/samba3/files/smb.conf.template

index 124bf9b461e89d53c79e58cebb31c35cfef0a0e5..9743cbfa28a89f6ffcdc937d8827dbf5aea16973 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=samba3
 PKG_VERSION:=3.0.37
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_MD5SUM:=11ed2bfef4090bd5736b194b43f67289
 
index 1dfe53da3be2920d6922f993b2125cb8c1584fe4..908f536e0f184bc9512a3a61407aea1f5a73c2f7 100644 (file)
@@ -1,16 +1,29 @@
+# Base server settings
 config samba
-       option 'name'                   'openwrt'
-       option 'workgroup'              'openwrt'
-       option 'description'    'openwrt'
-       option 'homes'                  '1'
-       list 'interface'                'lo'
-       list 'interface'                'lan'
-               
+       ## Override if desired, defaults to hostname
+       #option 'name'                  'OpenWrt'
+       #option 'workgroup'             'OpenWrt'
+       #option 'description'           'Samba on OpenWrt'
+
+       ## 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
        option 'name'                   'tmp'
        option 'path'                   '/tmp'
        option 'read_only'              'no'
        option 'guest_ok'               'no'
-       option 'create_mask'    '0700'
+       option 'create_mask'            '0700'
        option 'dir_mask'               '0700'
        #option 'users'                 'abc'
index 3e46431f56d7d684d79201a8468ddad817d4eb89..6d755ea7edfecdb74e0cd33072238c391810b40b 100755 (executable)
@@ -4,42 +4,63 @@
 START=60
 
 smb_header() {
-       local name
-       local workgroup
-       local description
-       local homes
        local interface
-
-       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"
+       config_get interface $1 interface "loopback lan"
 
        # resolve interfaces
        local interfaces=$(
                include /lib/network
                scan_interfaces
-               local net ifname; for net in $interface; do
-                       config_get ifname "$net" ifname "$net"
-                       echo -n "$ifname "
+
+               local net
+               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
        )
 
-       [ -z "$name" ] && name=openwrt
-       [ -z "$workgroup" ] && workgroup=openwrt
-       [ -z "$description" ] && description=openwrt
+       local name workgroup description charset
+       local hostname="$(uci_get system.@system[0].hostname)"
+
+       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
-       cp /etc/samba/smb.conf.template /var/etc/smb.conf
-       [ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
-       sed -i "s/|NAME|/$name/g" /var/etc/smb.conf
-       sed -i "s/|WORKGROUP|/$workgroup/g" /var/etc/smb.conf
-       sed -i "s/|DESCRIPTION|/$description/g" /var/etc/smb.conf
-       sed -i "s/|INTERFACES|/$interfaces/g" /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
+       sed -e "s#|NAME|#$name#g" \
+           -e "s#|WORKGROUP|#$workgroup#g" \
+           -e "s#|DESCRIPTION|#$description#g" \
+           -e "s#|INTERFACES|#$interfaces#g" \
+           -e "s#|CHARSET|#$charset#g" \
+           /etc/samba/smb.conf.template > /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() {
index 969a83ed5fb29749ac867cbe8e760e2495e637b0..0780a7312025a56b2e67d45b930d1c1d0b5f94f5 100644 (file)
@@ -7,7 +7,7 @@
        passdb backend = smbpasswd
        obey pam restrictions = yes
        socket options = TCP_NODELAY
-       unix charset = ISO-8859-1
+       unix charset = |CHARSET|
        preferred master = yes
        os level = 20
        security = share