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.

58 lines
1.2 KiB

  1. #!/bin/sh /etc/rc.common
  2. USE_PROCD=1
  3. START=99
  4. CONF="xray"
  5. PROG="/usr/bin/xray"
  6. start_service() {
  7. config_load "$CONF"
  8. local enabled
  9. config_get enabled "enabled" "enabled" "0"
  10. [ "$enabled" -eq "0" ] && exit 1
  11. local confdir
  12. local conffiles
  13. local datadir
  14. local dialer
  15. local format
  16. config_get confdir "config" "confdir"
  17. config_get conffiles "config" "conffiles"
  18. config_get datadir "config" "datadir" "/usr/share/xray"
  19. config_get dialer "config" "dialer"
  20. config_get format "config" "format" "json"
  21. procd_open_instance "$CONF"
  22. procd_set_param command "$PROG" run
  23. [ -n "$confdir" ] && procd_append_param command -confdir "$confdir"
  24. [ -n "$conffiles" ] && {
  25. for i in $conffiles
  26. do
  27. procd_append_param command -config "$i"
  28. done
  29. }
  30. [ -n "$format" ] && procd_append_param command -format "$format"
  31. [ -n "$dialer" ] && procd_set_param env XRAY_BROWSER_DIALER="$dialer"
  32. procd_set_param env XRAY_LOCATION_ASSET="$datadir"
  33. procd_set_param file $conffiles
  34. procd_set_param limits core="unlimited"
  35. procd_set_param limits nofile="1000000 1000000"
  36. procd_set_param stdout 1
  37. procd_set_param stderr 1
  38. procd_set_param respawn
  39. procd_close_instance
  40. }
  41. reload_service() {
  42. stop
  43. start
  44. }
  45. service_triggers() {
  46. procd_add_reload_trigger "$CONF"
  47. }