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.

54 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=90
  4. USE_PROCD=1
  5. start_instance() {
  6. local cfg="$1"
  7. config_get repository "$cfg" repository
  8. if [ -z "$repository" ]; then
  9. echo "repository is not defined in $1, skipping"
  10. return
  11. fi
  12. config_get_bool create "$cfg" create 0
  13. if [ "$create" -eq 0 -a ! -f "$repository" ]; then
  14. echo "in $1 create option is '$create' and repository '$repository' is not a regular file, skipping"
  15. return
  16. fi
  17. if [ "$create" -eq 1 -a ! -d `dirname $repository` ]; then
  18. mkdir -p `dirname $repository`
  19. if [ "$?" -ne 0 ]; then
  20. echo "could not create directory, skipping"
  21. return
  22. fi
  23. fi
  24. config_get port "$cfg" port ""
  25. if [ -z "$port" ]; then
  26. echo "port is not defined in $1, skipping"
  27. return
  28. fi
  29. config_get_bool debug "$cfg" debug 0
  30. config_get_bool localhost "$cfg" localhost 1
  31. config_get_bool scgi "$cfg" scgi 0
  32. procd_open_instance
  33. procd_set_param command /usr/bin/fossil server "$repository" --port $port
  34. [ "$debug" -eq 1 ] && procd_append_param command --th-trace
  35. [ "$create" -eq 1 ] && procd_append_param command --user root --create
  36. [ "$localhost" -eq 1 ] && procd_append_param command --localhost
  37. [ "$scgi" -eq 1 ] && procd_append_param command --scgi
  38. procd_set_param respawn
  39. procd_close_instance
  40. }
  41. start_service() {
  42. config_load 'fossil'
  43. config_foreach start_instance 'server'
  44. }