blob: 270e32c248e0b358d6179508d68d7765c4c1a08f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
logger $ACTION $DEVNAME $DEVTYPE
[ "$ACTION" = "add" ] && {
[ "$DEVTYPE" = "partition" -o "$DEVTYPE" = "disk" ] && {
[ "${DEVNAME:0:2}" = "sd" ] && {
[ "$(mount | grep $DEVNAME | cut -d ' ' -f1 | tr -d '\n')" = "/dev/$DEVNAME" ] && {
section=`/sbin/uci add samba sambashare`
/sbin/uci rename samba.$section=usb$DEVNAME
/sbin/uci set samba.usb$DEVNAME.name=usb$DEVNAME
/sbin/uci set samba.usb$DEVNAME.path=/mnt/$DEVNAME
/sbin/uci set samba.usb$DEVNAME.read_only=no
/sbin/uci set samba.usb$DEVNAME.guest_ok=yes
/sbin/uci set samba.usb$DEVNAME.create_mask=777
/sbin/uci set samba.usb$DEVNAME.dir_mask=777
/sbin/uci commit
chmod 777 /mnt/$DEVNAME
touch /tmp/smb.flag
smp.sh storage
/etc/init.d/samba restart
}
}
}
}
[ "$ACTION" = "remove" ] && {
[ "$DEVTYPE" = "partition" -o "$DEVTYPE" = "disk" ] && {
[ "${DEVNAME:0:2}" = "sd" ] && {
[ `/sbin/uci get samba.usb$DEVNAME.name` = "" ] && break
[ `/sbin/uci get samba.usb$DEVNAME.name` = "usb$DEVNAME" ] && {
/sbin/uci delete samba.usb$DEVNAME
/sbin/uci commit
}
ret=$(/sbin/uci get samba.@sambashare[0] 2>&1 | awk '{print $3}' | tr -d '\n')
[ $ret = "not" ] && {
/etc/init.d/samba stop
rm -f /tmp/smb.flag
}
[ $ret = "not" ] || {
/etc/init.d/samba restart
}
}
}
}
|