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.

51 lines
1.1 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_instance() {
  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. config_get confdir "config" "confdir"
  17. config_get conffiles "config" "conffiles"
  18. config_get datadir "config" "datadir" "/usr/share/xray"
  19. config_get format "config" "format" "json"
  20. procd_open_instance
  21. procd_set_param command "$PROG" run
  22. [ -n "$confdir" ] && procd_append_param command -confdir "$confdir"
  23. [ -n "$conffiles" ] && {
  24. for i in $conffiles
  25. do
  26. procd_append_param command -config "$i"
  27. done
  28. }
  29. procd_append_param command -format "$format"
  30. procd_set_param env XRAY_LOCATION_ASSET="$datadir"
  31. procd_set_param file $conffiles
  32. procd_set_param stdout 1
  33. procd_set_param stderr 1
  34. procd_set_param respawn
  35. [ -x "/sbin/ujail" -a -e "$CAPA_FILE" ] && {
  36. procd_add_jail xray
  37. procd_set_param capabilities "$CAPA_FILE"
  38. procd_set_param user nobody
  39. procd_set_param no_new_privs 1
  40. }
  41. procd_close_instance
  42. }