aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/network/services/samba36/Makefile12
-rw-r--r--package/network/services/samba36/files/samba.hotplug56
2 files changed, 68 insertions, 0 deletions
diff --git a/package/network/services/samba36/Makefile b/package/network/services/samba36/Makefile
index b63c2eaad3..a08b51ba17 100644
--- a/package/network/services/samba36/Makefile
+++ b/package/network/services/samba36/Makefile
@@ -43,6 +43,12 @@ define Package/samba36-server
DEPENDS:=+USE_GLIBC:librt $(ICONV_DEPENDS)
endef
+define Package/samba36-hotplug
+ $(call Package/samba/Default)
+ TITLE+= hotplug script for auto sharing
+ DEPENDS:=+blockd
+endef
+
define Package/samba36-client
$(call Package/samba/Default)
TITLE+= client
@@ -161,6 +167,11 @@ define Package/samba36-server/install
$(LN) samba_multicall $(1)/usr/sbin/smbpasswd
endef
+define Package/samba36-hotplug/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/mount
+ $(INSTALL_CONF) ./files/samba.hotplug $(1)/etc/hotplug.d/mount/60-samba
+endef
+
define Package/samba36-client/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_BIN)/smbclient $(1)/usr/sbin
@@ -174,5 +185,6 @@ endef
$(eval $(call BuildPackage,samba36-client))
$(eval $(call BuildPackage,samba36-server))
+$(eval $(call BuildPackage,samba36-hotplug))
$(eval $(call BuildPackage,samba36-net))
diff --git a/package/network/services/samba36/files/samba.hotplug b/package/network/services/samba36/files/samba.hotplug
new file mode 100644
index 0000000000..e1ae64e655
--- /dev/null
+++ b/package/network/services/samba36/files/samba.hotplug
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+. /usr/share/libubox/jshn.sh
+
+device_get_vars() {
+ json_init
+ json_load "$(ubus call block info)"
+
+ json_select devices
+
+ json_get_keys keys
+ for key in $keys
+ do
+ json_select $key
+
+ json_get_var device device
+ [ "$device" = "$1" ] && {
+ shift
+ json_get_vars $@
+ json_select ..
+ break
+ }
+
+ json_select ..
+ done
+
+ json_select ..
+}
+
+[ -f /var/run/config/samba ] || {
+ mkdir -p /var/run/config && touch /var/run/config/samba
+}
+
+[ "$ACTION" = "add" ] && {
+ device_get_vars $DEVICE label mount
+ [ -n "$mount" ] && {
+ uci -c /var/run/config batch <<-EOF
+ set samba.$DEVICE="sambashare"
+ set samba.$DEVICE.name="$label"
+ set samba.$DEVICE.path="$mount"
+ set samba.$DEVICE.browseable="yes"
+ set samba.$DEVICE.read_only="yes"
+ set samba.$DEVICE.guest_ok="yes"
+ commit samba
+ EOF
+ /etc/init.d/samba reload
+ }
+}
+
+[ "$ACTION" = "remove" ] && {
+ uci -c /var/run/config batch <<-EOF
+ delete samba.$DEVICE
+ commit samba
+ EOF
+ /etc/init.d/samba reload
+}