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.

66 lines
1.5 KiB

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