summaryrefslogtreecommitdiff
path: root/package/system/fstools/files/samba.hotplug
diff options
context:
space:
mode:
Diffstat (limited to 'package/system/fstools/files/samba.hotplug')
-rw-r--r--package/system/fstools/files/samba.hotplug47
1 files changed, 47 insertions, 0 deletions
diff --git a/package/system/fstools/files/samba.hotplug b/package/system/fstools/files/samba.hotplug
new file mode 100644
index 0000000..270e32c
--- /dev/null
+++ b/package/system/fstools/files/samba.hotplug
@@ -0,0 +1,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
+ }
+ }
+ }
+}
+
+