Ksmbd (smb/445) Daemon service via mDNS/DNS-SD.
endef
+define Package/ksmbd-hotplug
+ $(call Package/ksmbd-tools/Default)
+ TITLE+= hotplug script for auto sharing
+ DEPENDS:=+blockd
+endef
+
MESON_ARGS += \
-Db_lto=true \
-Dkrb5=disabled
$(INSTALL_DATA) ./files/smb.service $(1)/etc/avahi/services/
endef
+define Package/ksmbd-hotplug/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/mount
+ $(INSTALL_CONF) ./files/ksmbd.hotplug $(1)/etc/hotplug.d/mount/60-ksmbd
+endef
+
define Package/ksmbd-server/conffiles
/etc/config/ksmbd
/etc/ksmbd/smb.conf.template
$(eval $(call BuildPackage,ksmbd-server))
$(eval $(call BuildPackage,ksmbd-utils))
$(eval $(call BuildPackage,ksmbd-avahi-service))
+$(eval $(call BuildPackage,ksmbd-hotplug))
--- /dev/null
+#!/bin/sh
+
+. /usr/share/libubox/jshn.sh
+
+device_get_vars() {
+ json_init
+ json_load "$(ubus call block info)"
+
+ json_select devices || return 1
+
+ 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 ..
+ json_select ..
+ return 0
+ }
+
+ json_select ..
+ done
+
+ json_select ..
+
+ return 2
+}
+
+[ -f /var/run/config/ksmbd ] || {
+ mkdir -p /var/run/config && touch /var/run/config/ksmbd
+}
+
+[ "$ACTION" = "add" ] && {
+ device_get_vars $DEVICE label mount || {
+ logger -t ksmbd-hotplug "Failed to get $DEVICE info"
+ exit 1
+ }
+ [ -n "$mount" ] && {
+ uci -c /var/run/config batch <<-EOF
+ set ksmbd.$DEVICE="share"
+ set ksmbd.$DEVICE.name="${label:-$DEVICE}"
+ set ksmbd.$DEVICE.path="$mount"
+ set ksmbd.$DEVICE.browseable="yes"
+ set ksmbd.$DEVICE.read_only="yes"
+ set ksmbd.$DEVICE.guest_ok="yes"
+ commit ksmbd
+ EOF
+ /etc/init.d/ksmbd reload
+ }
+}
+
+[ "$ACTION" = "remove" ] && {
+ uci -c /var/run/config batch <<-EOF
+ delete ksmbd.$DEVICE
+ commit ksmbd
+ EOF
+ /etc/init.d/ksmbd reload
+}