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.

63 lines
1.4 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 format
  16. local fullcone
  17. config_get confdir "config" "confdir"
  18. config_get conffiles "config" "conffiles"
  19. config_get datadir "config" "datadir" "/usr/share/xray"
  20. config_get format "config" "format" "json"
  21. config_get fullcone "enabled" "fullcone" "0"
  22. procd_open_instance "$CONF"
  23. procd_set_param command "$PROG" run
  24. [ -n "$confdir" ] && procd_append_param command -confdir "$confdir"
  25. [ -n "$conffiles" ] && {
  26. for i in $conffiles
  27. do
  28. procd_append_param command -config "$i"
  29. done
  30. }
  31. procd_append_param command -format "$format"
  32. [ "$fullcone" -eq "0" ] && procd_set_param env XRAY_CONE_DISABLED="true"
  33. procd_set_param env XRAY_LOCATION_ASSET="$datadir"
  34. procd_set_param file $conffiles
  35. procd_set_param stdout 1
  36. procd_set_param stderr 1
  37. procd_set_param respawn
  38. [ -x "/sbin/ujail" -a -e "$CAPA_FILE" ] && {
  39. procd_add_jail "$CONF"
  40. procd_set_param capabilities "$CAPA_FILE"
  41. procd_set_param user nobody
  42. procd_set_param no_new_privs 1
  43. }
  44. procd_close_instance
  45. }
  46. reload_service() {
  47. stop
  48. start
  49. }
  50. service_triggers() {
  51. procd_add_reload_trigger "$CONF"
  52. }