OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | #!/bin/sh |
1 | . /lib/samba/samba.sh |
|
Line 2... | Line 2... | |||
2 | |
2 | |
|
- | 3 | samba_dev_filter $DEVNAME |
||
Line 3... | Line -... | |||
3 | . /usr/share/libubox/jshn.sh |
- | ||
4 | |
- | ||
5 | device_get_vars() { |
- | ||
6 | json_init |
- | ||
7 | json_load "$(ubus call block info)" |
- | ||
8 | |
- | ||
9 | json_select devices |
4 | [ "$FLAG_DEV_TYPE" = "not-mtd" ] || exit |
|
10 | |
- | ||
11 | json_get_keys keys |
- | ||
12 | for key in $keys |
- | ||
13 | do |
- | ||
14 | json_select $key |
- | ||
15 | |
- | ||
16 | json_get_var device device |
- | ||
17 | [ "$device" = "$1" ] && { |
- | ||
18 | shift |
- | ||
19 | json_get_vars $@ |
- | ||
20 | json_select .. |
- | ||
21 | break |
- | ||
22 | } |
- | ||
23 | |
- | ||
24 | json_select .. |
- | ||
25 | done |
5 | |
|
26 | |
- | ||
27 | json_select .. |
- | ||
28 | } |
- | ||
29 | |
- | ||
30 | [ -f /var/run/config/samba ] || { |
- | ||
31 | mkdir -p /var/run/config && touch /var/run/config/samba |
- | ||
32 | } |
- | ||
33 | |
- | ||
34 | [ "$ACTION" = "add" ] && { |
- | ||
35 | device_get_vars $DEVICE label mount |
- | ||
36 | [ -n "$mount" ] && { |
- | ||
37 | uci -c /var/run/config batch <<-EOF |
- | ||
38 | set samba.$DEVICE="sambashare" |
- | ||
39 | set samba.$DEVICE.name="$label" |
6 | config_load samba |
|
40 | set samba.$DEVICE.path="$mount" |
7 | case $ACTION in |
|
41 | set samba.$DEVICE.browseable="yes" |
- | ||
42 | set samba.$DEVICE.read_only="yes" |
- | ||
43 | set samba.$DEVICE.guest_ok="yes" |
8 | add) samba_add_section $DEVNAME;; |
|
44 | commit samba |
- | ||
45 | EOF |
- | ||
46 | /etc/init.d/samba reload |
- | ||
47 | } |
- | ||
48 | } |
- | ||
49 | |
- | ||
50 | [ "$ACTION" = "remove" ] && { |
- | ||
51 | uci -c /var/run/config batch <<-EOF |
9 | remove) samba_delete_section $DEVNAME;; |
|
52 | delete samba.$DEVICE |
- | ||
53 | commit samba |
- | ||
54 | EOF |
- |