summaryrefslogtreecommitdiffstats
path: root/package/network/services/samba36/files
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-10 12:34:29 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-10 12:34:29 +0000
commit762ba61479c80e47ef75dee687621473f3d25ca4 (patch)
tree3e88aeda2912a0011f5a69a0ec21f1febdd22d52 /package/network/services/samba36/files
parent9c8997d54dc9df184bfcedeabf0b3c85cf5e6753 (diff)
samba36: move to trunk and add myself as a maintainer
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33689 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/services/samba36/files')
-rw-r--r--package/network/services/samba36/files/samba.config6
-rwxr-xr-xpackage/network/services/samba36/files/samba.init97
-rw-r--r--package/network/services/samba36/files/smb.conf.template34
3 files changed, 137 insertions, 0 deletions
diff --git a/package/network/services/samba36/files/samba.config b/package/network/services/samba36/files/samba.config
new file mode 100644
index 000000000..c79db0d32
--- /dev/null
+++ b/package/network/services/samba36/files/samba.config
@@ -0,0 +1,6 @@
+config samba
+ option 'name' 'OpenWrt'
+ option 'workgroup' 'WORKGROUP'
+ option 'description' 'OpenWrt'
+ option 'homes' '1'
+
diff --git a/package/network/services/samba36/files/samba.init b/package/network/services/samba36/files/samba.init
new file mode 100755
index 000000000..61398d8f4
--- /dev/null
+++ b/package/network/services/samba36/files/samba.init
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=60
+
+smb_header() {
+ local interface
+ config_get interface $1 interface "loopback lan"
+
+ # resolve interfaces
+ local interfaces=$(
+ . /lib/functions/network.sh
+
+ local net
+ for net in $interface; do
+ local device
+ network_get_device device "$net" && {
+ local subnet
+ network_get_subnet subnet "$net" && echo -n "$subnet "
+ network_get_subnet6 subnet "$net" && echo -n "$subnet "
+ }
+
+ echo -n "${device:-$net} "
+ done
+ )
+
+ 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
+ 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() {
+ local name
+ local path
+ local users
+ local read_only
+ local guest_ok
+ local create_mask
+ local dir_mask
+
+ config_get name $1 name
+ config_get path $1 path
+ config_get users $1 users
+ config_get read_only $1 read_only
+ config_get guest_ok $1 guest_ok
+ config_get create_mask $1 create_mask
+ config_get dir_mask $1 dir_mask
+
+ [ -z "$name" -o -z "$path" ] && return
+
+ echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
+ [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
+ [ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
+ [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
+ [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
+ [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
+}
+
+start() {
+ config_load samba
+ config_foreach smb_header samba
+ config_foreach smb_add_share sambashare
+ service_start /usr/sbin/smbd -D
+ service_start /usr/sbin/nmbd -D
+}
+
+stop() {
+ service_stop /usr/sbin/smbd
+ service_stop /usr/sbin/nmbd
+}
diff --git a/package/network/services/samba36/files/smb.conf.template b/package/network/services/samba36/files/smb.conf.template
new file mode 100644
index 000000000..38a385574
--- /dev/null
+++ b/package/network/services/samba36/files/smb.conf.template
@@ -0,0 +1,34 @@
+[global]
+ netbios name = |NAME|
+ display charset = |CHARSET|
+ interfaces = |INTERFACES|
+ server string = |DESCRIPTION|
+ unix charset = |CHARSET|
+ workgroup = |WORKGROUP|
+ browseable = yes
+ deadtime = 30
+ domain master = yes
+ encrypt passwords = true
+ enable core files = no
+ guest account = nobody
+ guest ok = yes
+ invalid users = root
+ local master = yes
+ load printers = no
+ map to guest = Bad User
+ max protocol = SMB2
+ min receivefile size = 16384
+ null passwords = yes
+ obey pam restrictions = yes
+ os level = 20
+ passdb backend = smbpasswd
+ preferred master = yes
+ printable = no
+ security = user
+ smb encrypt = disabled
+ smb passwd file = /etc/samba/smbpasswd
+ socket options = TCP_NODELAY IPTOS_LOWDELAY
+ syslog = 2
+ use sendfile = yes
+ writeable = yes
+