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:=2019-12-15
-PKG_SOURCE_VERSION:=8bcc0c1a42767ba518977a7104fe934f5d89ef31
-PKG_MIRROR_HASH:=4eace9130b7e1ddbc5b965fa51286532d3ee2ee14bcd2e116840c7d6d48ad9bc
+PKG_SOURCE_DATE:=2020-05-06
+PKG_SOURCE_VERSION:=671d040c33ec290930535e27dd59c1e5ccec11ec
+PKG_MIRROR_HASH:=aac0881ba8627897b23906eabde97450178a8f9285699c0368f88a745a934b96
PKG_MAINTAINER:=Andy Walsh <andy.walsh44+github@gmail.com>
PKG_LICENSE:=GPL-3.0-only
SMB_CONF=""
BIND_IF_PARM=""
-NB_PARM=""
-WG_PARM=""
+NB_PARM="$(cat /proc/sys/kernel/hostname)"
+WG_PARM="WORKGROUP"
BI_PARM=""
start_service() {
SMB_CONF="/etc/ksmbd/smb.conf"
fi
- if [ -e /etc/samba/smb.conf ]; then
+ [ -e /etc/samba/smb.conf ] && {
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
+ }
+
+ [ -z "$SMB_CONF" ] && {
logger -p daemon.error -t 'wsdd2' "samba36/4 or ksmbd 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
+ [ -n "$nb_name" ] && NB_PARM="$nb_name"
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
- WG_PARM="-G WORKGROUP"
- fi
+ [ -n "$wg_name" ] && WG_PARM="$wg_name"
# resolve lan interface (BUG: No multi-interface binds atm)
local ifname
- if network_get_device ifname lan; then
- BIND_IF_PARM="-i $ifname"
- fi
+ network_get_device ifname lan
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
+ [ -e /tmp/sysinfo/board_name ] && {
+ board_vendor="$(awk -F',' '{print $1}' /tmp/sysinfo/board_name | tr ' ' '_' | tr -d ' \n')"
+ board_sku="$(awk -F',' '{print $2}' /tmp/sysinfo/board_name | tr ' ' '_' | tr -d ' \n')"
+ }
+
+ [ -e /tmp/sysinfo/model ] && {
+ board_model="$(awk -F':' '{print $1}' /tmp/sysinfo/model | tr ' ' '_' | tr -d ' \n')"
+ }
+
+ [ -n "$board_vendor" ] && [ -n "$board_model" ] && {
if [ -n "$board_sku" ]; then
- BI_PARM="-b vendor:$board_vendor,model:$board_model,sku:$board_sku"
+ BI_PARM="vendor:$board_vendor,model:$board_model,sku:$board_sku"
else
- BI_PARM="-b vendor:$board_vendor,model:$board_model"
+ BI_PARM="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 $SMB_CONF
- procd_close_instance
+ procd_set_param command /usr/bin/wsdd2
+ [ -n "$ifname" ] && procd_append_param command -i "$ifname"
+ procd_append_param command -N "$NB_PARM"
+ procd_append_param command -G "$WG_PARM"
+ [ "x${BI_PARM}" = "x" ] || procd_append_param command -b "$BI_PARM"
+ procd_set_param respawn
+ procd_set_param file "$SMB_CONF"
+ procd_close_instance
}
service_triggers() {