1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008-2012 OpenWrt.org
8 config_get samba_iface $1 interface "loopback lan"
12 . /lib/functions/network.sh
15 for net in $samba_iface; do
17 network_is_up $net || continue
18 network_get_device device "$net" && {
20 network_get_subnet subnet "$net" && echo -n "$subnet "
21 network_get_subnet6 subnet "$net" && echo -n "$subnet "
24 echo -n "${device:-$net} "
28 local name workgroup description charset
29 local hostname="$(uci_get system.@system[0].hostname)"
31 config_get name $1 name "${hostname:-Lede}"
32 config_get workgroup $1 workgroup "${hostname:-Lede}"
33 config_get description $1 description "Samba on ${hostname:-Lede}"
34 config_get charset $1 charset "UTF-8"
37 sed -e "s#|NAME|#$name#g" \
38 -e "s#|WORKGROUP|#$workgroup#g" \
39 -e "s#|DESCRIPTION|#$description#g" \
40 -e "s#|INTERFACES|#$interfaces#g" \
41 -e "s#|CHARSET|#$charset#g" \
42 /etc/samba/smb.conf.template > /var/etc/smb.conf
45 config_get_bool homes $1 homes 0
47 cat <<EOT >> /var/etc/smb.conf
50 comment = Home Directories
57 [ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
70 config_get name $1 name
71 config_get path $1 path
72 config_get users $1 users
73 config_get read_only $1 read_only
74 config_get guest_ok $1 guest_ok
75 config_get create_mask $1 create_mask
76 config_get dir_mask $1 dir_mask
77 config_get browseable $1 browseable
79 [ -z "$name" -o -z "$path" ] && return
81 echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
82 [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
83 [ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
84 [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
85 [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
86 [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
87 [ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" >> /var/etc/smb.conf
92 config_foreach smb_header samba
93 config_foreach smb_add_share sambashare
97 procd_add_reload_trigger samba
100 for i in $samba_iface; do
101 procd_add_reload_interface_trigger $i
109 procd_set_param command /usr/sbin/smbd -F
110 procd_set_param respawn
111 procd_set_param file /var/etc/smb.conf
115 procd_set_param command /usr/sbin/nmbd -F
116 procd_set_param respawn
117 procd_set_param file /var/etc/smb.conf