From e1a305a355e00f0b45ecb6e4e711247e23e15000 Mon Sep 17 00:00:00 2001 From: Andy Walsh Date: Sun, 15 Dec 2019 17:11:25 +0100 Subject: [PATCH] wsdd2: update to git (2019-12-15), bind to 'lan' only * update to git (2019-12-15) * bind to 'lan' interface only * make cifsd compatible (avoid testparm dependency) * only start if needed * add meta data (vendor, model, sku) * update smb.conf procd location * lower restart delay * remove outdated patch Signed-off-by: Andy Walsh --- net/wsdd2/Makefile | 8 +- net/wsdd2/files/wsdd2.init | 79 ++++++++++++++++++-- net/wsdd2/patches/001-add_uuid_boot_id.patch | 25 ------- 3 files changed, 78 insertions(+), 34 deletions(-) delete mode 100644 net/wsdd2/patches/001-add_uuid_boot_id.patch diff --git a/net/wsdd2/Makefile b/net/wsdd2/Makefile index 9b921dae9..24c3f0e88 100644 --- a/net/wsdd2/Makefile +++ b/net/wsdd2/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wsdd2 -PKG_RELEASE:=3 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/Andy2244/wsdd2.git -PKG_SOURCE_DATE:=2018-07-24 -PKG_SOURCE_VERSION:=2c31ba3b720af81848c47dff7ad7c6c30c0c0f50 -PKG_MIRROR_HASH:=eb903a870d99c6001996dbfc22c15e1020278c45ed2441ceb61bc5395f417afa +PKG_SOURCE_DATE:=2019-12-15 +PKG_SOURCE_VERSION:=8bcc0c1a42767ba518977a7104fe934f5d89ef31 +PKG_MIRROR_HASH:=4eace9130b7e1ddbc5b965fa51286532d3ee2ee14bcd2e116840c7d6d48ad9bc PKG_MAINTAINER:=Andy Walsh PKG_LICENSE:=GPL-3.0-only diff --git a/net/wsdd2/files/wsdd2.init b/net/wsdd2/files/wsdd2.init index 29272f942..4ade08279 100644 --- a/net/wsdd2/files/wsdd2.init +++ b/net/wsdd2/files/wsdd2.init @@ -3,15 +3,84 @@ START=99 USE_PROCD=1 +SMB_CONF="" +BIND_IF_PARM="" +NB_PARM="" +WG_PARM="" +BI_PARM="" + +. /lib/functions/network.sh + start_service() { - procd_open_instance - procd_set_param command /usr/bin/wsdd2 -w + + if [ -e /etc/cifs/smb.conf ] && [ -e /etc/init.d/cifsd ] && /etc/init.d/cifsd running; then + SMB_CONF="/etc/cifs/smb.conf" + fi + + if [ -e /etc/samba/smb.conf ]; then + if [ -e /etc/init.d/samba4 ] && /etc/init.d/samba4 running; then + SMB_CONF="/etc/samba/smb.conf" + elif [ -e /etc/init.d/samba ] && /etc/init.d/samba running; then + SMB_CONF="/etc/samba/smb.conf" + fi + fi + + if [ -z "$SMB_CONF" ]; then + logger -p daemon.error -t 'wsdd2' "samba36/4 or cifsd is not running, can't start wsdd2!" + exit 1 + fi + + local nb_name + nb_name="$(grep -i 'netbios name' $SMB_CONF | awk -F'=' '{print $2}' | tr -d ' \n')" + if [ -n "$nb_name" ]; then + NB_PARM="-N $nb_name" + else + local hostname + hostname="$(cat /proc/sys/kernel/hostname)" + NB_PARM="-N $hostname" + fi + + local wg_name + wg_name="$(grep -i 'workgroup' $SMB_CONF | awk -F'=' '{print $2}' | tr -d ' \n')" + if [ -n "$wg_name" ]; then + WG_PARM="-G $wg_name" + else + NB_PARM="-G WORKGROUP" + fi + + # resolve lan interface (BUG: No multi-interface binds atm) + local ifname + if network_get_device ifname lan; then + BIND_IF_PARM="-i $ifname" + fi + + local board_vendor + local board_model + local board_sku + + if [ -e /tmp/sysinfo/board_name ]; then + board_vendor="$(cat /tmp/sysinfo/board_name | awk -F',' '{print $1}' | tr ' ' '_' | tr -d ' \n')" + board_sku="$(cat /tmp/sysinfo/board_name | awk -F',' '{print $2}' | tr ' ' '_' | tr -d ' \n')" + fi + if [ -e /tmp/sysinfo/model ]; then + board_model="$(cat /tmp/sysinfo/model | tr ' ' '_' | tr -d ' \n')" + fi + if [ -n "$board_vendor" ] && [ -n "$board_model" ]; then + if [ -n "$board_sku" ]; then + BI_PARM="-b vendor:$board_vendor,model:$board_model,sku:$board_sku" + else + BI_PARM="-b vendor:$board_vendor,model:$board_model" + fi + fi + + procd_open_instance + procd_set_param command /usr/bin/wsdd2 -w $BIND_IF_PARM $NB_PARM $WG_PARM $BI_PARM procd_set_param respawn - procd_set_param file /var/etc/smb.conf + procd_set_param file $SMB_CONF procd_close_instance } service_triggers() { - PROCD_RELOAD_DELAY=3000 - procd_add_reload_trigger "dhcp" "system" "samba4" + PROCD_RELOAD_DELAY=1000 + procd_add_reload_trigger "dhcp" "system" "samba" "samba4" "cifsd" } diff --git a/net/wsdd2/patches/001-add_uuid_boot_id.patch b/net/wsdd2/patches/001-add_uuid_boot_id.patch deleted file mode 100644 index 0c59365a1..000000000 --- a/net/wsdd2/patches/001-add_uuid_boot_id.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/wsd.c 2018-07-24 -+++ b/wsd.c 2018-09-10 -@@ -96,13 +96,19 @@ static void uuid_endpoint(char *uuid, si - { - FILE *fp = fopen("/etc/machine-id", "r"); - int c, i = 0; -+ -+ if (!fp) { -+ fp = fopen("/proc/sys/kernel/random/boot_id", "r"); -+ } - -- if (!fp) -+ if (!fp) { -+ DEBUG(0, W, "Can't open required '/etc/machine-id' or '/proc/sys/kernel/random/boot_id'"); - return; -+ } - - while (i < 36 && (c = getc(fp)) != EOF && -- (isdigit(c) || (islower(c) && isxdigit(c)))) { -- if (i == 8 || i == 13 || i == 18 || i == 23) -+ ((c == '-') || isdigit(c) || (islower(c) && isxdigit(c)))) { -+ if ((c != '-') && (i == 8 || i == 13 || i == 18 || i == 23)) - uuid[i++] = '-'; - uuid[i++] = c; - }