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.

70 lines
1.5 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_env() {
  17. procd_append_param env "V2RAYA_$(echo "$1" | tr "[a-z]" "[A-Z]")"="$2"
  18. }
  19. append_env_arg() {
  20. local value
  21. config_get value "$1" "$2" $3
  22. [ -n "$value" ] && append_env "$2" "$value"
  23. }
  24. append_env_bool() {
  25. is_enabled "$1" "$2" && append_env "$2" "true"
  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. procd_set_param env XDG_DATA_HOME="/usr/share"
  33. append_env_arg "config" "address" "0.0.0.0:2017"
  34. append_env_arg "config" "config" "/etc/v2raya"
  35. append_env_arg "config" "ipv6_support" "auto"
  36. append_env_arg "config" "log_level" "info"
  37. append_env_arg "config" "log_file" "/var/log/v2raya/v2raya.log"
  38. append_env_arg "config" "log_max_days" "3"
  39. append_env_arg "config" "v2ray_bin"
  40. append_env_arg "config" "v2ray_confdir"
  41. append_env_arg "config" "vless_grpc_inbound_cert_key"
  42. append_env_bool "config" "log_disable_color"
  43. append_env_bool "config" "log_disable_timestamp"
  44. procd_set_param limits core="unlimited"
  45. procd_set_param respawn
  46. procd_set_param stdout 1
  47. procd_set_param stderr 1
  48. procd_close_instance
  49. }
  50. reload_service() {
  51. stop
  52. start
  53. }
  54. service_triggers() {
  55. procd_add_reload_trigger "$CONF"
  56. }