diff --git a/net/wsdd2/Makefile b/net/wsdd2/Makefile index 222c792e6..b0cfe331e 100644 --- a/net/wsdd2/Makefile +++ b/net/wsdd2/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wsdd2 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/Andy2244/wsdd2.git diff --git a/net/wsdd2/files/wsdd2.init b/net/wsdd2/files/wsdd2.init index 24595e0f3..ee60eee2d 100644 --- a/net/wsdd2/files/wsdd2.init +++ b/net/wsdd2/files/wsdd2.init @@ -5,8 +5,8 @@ USE_PROCD=1 SMB_CONF="" BIND_IF_PARM="" -NB_PARM="" -WG_PARM="" +NB_PARM="$(cat /proc/sys/kernel/hostname)" +WG_PARM="WORKGROUP" BI_PARM="" start_service() { @@ -17,67 +17,61 @@ 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" + procd_append_param command -b "$BI_PARM" + procd_set_param respawn + procd_set_param file "$SMB_CONF" + procd_close_instance } service_triggers() {