You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=99
  3. USE_PROCD=1
  4. SMB_CONF=""
  5. BIND_IF_PARM=""
  6. NB_PARM="$(cat /proc/sys/kernel/hostname)"
  7. WG_PARM="WORKGROUP"
  8. BI_PARM=""
  9. start_service() {
  10. . /lib/functions/network.sh
  11. if [ -e /etc/ksmbd/smb.conf ] && [ -e /etc/init.d/ksmbd ] && /etc/init.d/ksmbd running; then
  12. SMB_CONF="/etc/ksmbd/smb.conf"
  13. fi
  14. [ -e /etc/samba/smb.conf ] && {
  15. if [ -e /etc/init.d/samba4 ] && /etc/init.d/samba4 running; then
  16. SMB_CONF="/etc/samba/smb.conf"
  17. elif [ -e /etc/init.d/samba ] && /etc/init.d/samba running; then
  18. SMB_CONF="/etc/samba/smb.conf"
  19. fi
  20. }
  21. [ -z "$SMB_CONF" ] && {
  22. logger -p daemon.error -t 'wsdd2' "samba36/4 or ksmbd is not running, can't start wsdd2!"
  23. exit 1
  24. }
  25. local nb_name
  26. nb_name="$(grep -i 'netbios name' $SMB_CONF | awk -F'=' '{print $2}' | tr -d ' \n')"
  27. [ -n "$nb_name" ] && NB_PARM="$nb_name"
  28. local wg_name
  29. wg_name="$(grep -i 'workgroup' $SMB_CONF | awk -F'=' '{print $2}' | tr -d ' \n')"
  30. [ -n "$wg_name" ] && WG_PARM="$wg_name"
  31. # resolve lan interface (BUG: No multi-interface binds atm)
  32. local ifname
  33. network_get_device ifname lan
  34. local board_vendor
  35. local board_model
  36. local board_sku
  37. [ -e /tmp/sysinfo/board_name ] && {
  38. board_vendor="$(awk -F',' '{print $1}' /tmp/sysinfo/board_name | tr ' ' '_' | tr -d ' \n')"
  39. board_sku="$(awk -F',' '{print $2}' /tmp/sysinfo/board_name | tr ' ' '_' | tr -d ' \n')"
  40. }
  41. [ -e /tmp/sysinfo/model ] && {
  42. board_model="$(awk -F':' '{print $1}' /tmp/sysinfo/model | tr ' ' '_' | tr -d ' \n')"
  43. }
  44. [ -n "$board_vendor" ] && [ -n "$board_model" ] && {
  45. if [ -n "$board_sku" ]; then
  46. BI_PARM="vendor:$board_vendor,model:$board_model,sku:$board_sku"
  47. else
  48. BI_PARM="vendor:$board_vendor,model:$board_model"
  49. fi
  50. }
  51. procd_open_instance
  52. procd_set_param command /usr/bin/wsdd2
  53. [ -n "$ifname" ] && procd_append_param command -i "$ifname"
  54. procd_append_param command -N "$NB_PARM"
  55. procd_append_param command -G "$WG_PARM"
  56. [ "x${BI_PARM}" = "x" ] || procd_append_param command -b "$BI_PARM"
  57. procd_set_param respawn
  58. procd_set_param file "$SMB_CONF"
  59. procd_close_instance
  60. }
  61. service_triggers() {
  62. PROCD_RELOAD_DELAY=1000
  63. procd_add_reload_trigger "dhcp" "system" "samba" "samba4" "ksmbd"
  64. }