1
0

owfs.init 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2015 OpenWrt.org
  3. START=95
  4. USE_PROCD=1
  5. PROG=/usr/bin/owfs
  6. append_arg() {
  7. local cfg="$1"
  8. local var="$2"
  9. local opt="$3"
  10. local def="$4"
  11. local val
  12. config_get val "$cfg" "$var"
  13. [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
  14. }
  15. append_bool() {
  16. local cfg="$1"
  17. local var="$2"
  18. local opt="$3"
  19. local def="$4"
  20. local val
  21. config_get_bool val "$cfg" "$var" "$def"
  22. [ "$val" = 1 ] && procd_append_param command "$opt"
  23. }
  24. append_plain() {
  25. procd_append_param command "$1"
  26. }
  27. append_param() {
  28. local cfg="$1"
  29. local var="$2"
  30. local opt="$3"
  31. local def="$4"
  32. local val
  33. config_get val "$cfg" "$var"
  34. [ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}"
  35. }
  36. start_instance() {
  37. local cfg="$1"
  38. local enabled
  39. config_get_bool enabled "$cfg" 'enabled' '0'
  40. [ "$enabled" = 0 ] && return 1
  41. procd_open_instance
  42. procd_set_param command "$PROG" --foreground --error_print=1
  43. # common parameters
  44. append_bool "$cfg" readonly "--readonly"
  45. append_arg "$cfg" error_level "--error_level"
  46. config_list_foreach "$cfg" options append_plain
  47. config_list_foreach "$cfg" devices append_plain
  48. append_param "$cfg" user user
  49. # owfs-specific
  50. append_arg "$cfg" mountpoint "--mountpoint" /mnt/owfs
  51. append_bool "$cfg" fuse_allow_other "--allow_other"
  52. append_arg "$cfg" fuse_open_opt "--fuse_open_opt"
  53. # don't respawn fuse
  54. procd_close_instance
  55. }
  56. service_triggers() {
  57. procd_add_reload_trigger owfs
  58. }
  59. start_service() {
  60. config_load owfs
  61. config_foreach start_instance owfs
  62. }