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.

69 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
  3. USE_PROCD=1
  4. START=99
  5. CONF="v2raya"
  6. PROG="/usr/bin/v2raya"
  7. is_enabled() {
  8. local enabled
  9. config_get_bool enabled "$1" "$2" "${3:-0}"
  10. if [ "$enabled" -eq "1" ]; then
  11. return 0
  12. else
  13. return 1
  14. fi
  15. }
  16. append_param() {
  17. procd_append_param command "$1" $2
  18. }
  19. append_param_arg() {
  20. local value
  21. config_get value "$1" "$2" $3
  22. [ -n "$value" ] && append_param "--${2//_/-}" "$value"
  23. }
  24. append_param_bool() {
  25. is_enabled "$1" "$2" && append_param "--${2//_/-}"
  26. }
  27. start_service() {
  28. config_load "$CONF"
  29. is_enabled "config" "enabled" || exit 1
  30. procd_open_instance "$CONF"
  31. procd_set_param command "$PROG"
  32. append_param_arg "config" "address" "0.0.0.0:2017"
  33. append_param_arg "config" "config" "/etc/v2raya"
  34. append_param_arg "config" "ipv6_support" "auto"
  35. append_param_arg "config" "log_level" "info"
  36. append_param_arg "config" "log_file" "/tmp/v2raya.log"
  37. append_param_arg "config" "log_max_days" "3"
  38. append_param_arg "config" "v2ray_bin"
  39. append_param_arg "config" "v2ray_confdir"
  40. append_param_arg "config" "vless_grpc_inbound_cert_key"
  41. append_param_bool "config" "log_disable_color"
  42. append_param_bool "config" "log_disable_timestamp"
  43. procd_set_param limits core="unlimited"
  44. procd_set_param respawn
  45. procd_set_param stdout 1
  46. procd_set_param stderr 1
  47. procd_close_instance
  48. }
  49. reload_service() {
  50. stop
  51. start
  52. }
  53. service_triggers() {
  54. procd_add_reload_trigger "$CONF"
  55. }