install-trgo.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #!/bin/bash
  2. # Trojan Go Auto Setup
  3. # =========================
  4. red='\e[1;31m'
  5. green='\e[0;32m'
  6. NC='\e[0m'
  7. MYIP=$(wget -qO- ifconfig.me/ip);
  8. clear
  9. # Domain
  10. domain=$(cat /etc/v2ray/domain)
  11. # Uuid Service
  12. uuid=$(cat /proc/sys/kernel/random/uuid)
  13. # Trojan Go Akun
  14. mkdir -p /etc/trojan-go/
  15. touch /etc/trojan-go/akun.conf
  16. touch /etc/trojan-go/uuid.txt
  17. # Installing Trojan Go
  18. mkdir -p /etc/trojan-go/
  19. chmod 777 /etc/trojan-go/
  20. touch /etc/trojan-go/trojan-go.pid
  21. wget -O /etc/trojan-go/trojan-go https://raw.githubusercontent.com/alifnurmareta/bc/main/trojan-go
  22. wget -O /etc/trojan-go/geoip.dat https://raw.githubusercontent.com/alifnurmareta/bc/main/geoip.dat
  23. wget -O /etc/trojan-go/geosite.dat https://raw.githubusercontent.com/alifnurmareta/bc/main/geosite.dat
  24. chmod +x /etc/trojan-go/trojan-go
  25. cat <<EOF > /etc/trojan-go/config.json
  26. {
  27. "run_type": "server",
  28. "local_addr": "0.0.0.0",
  29. "local_port": 2096,
  30. "remote_addr": "127.0.0.1",
  31. "remote_port": 81,
  32. "log_level": 1,
  33. "log_file": "/var/log/trojan-go.log",
  34. "password": [
  35. "$uuid"
  36. ],
  37. "disable_http_check": false,
  38. "udp_timeout": 60,
  39. "ssl": {
  40. "verify": true,
  41. "verify_hostname": true,
  42. "cert": "/etc/v2ray/v2ray.crt",
  43. "key": "/etc/v2ray/v2ray.key",
  44. "key_password": "",
  45. "cipher": "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
  46. "curves": "",
  47. "prefer_server_cipher": true,
  48. "sni": "$domain",
  49. "alpn": [
  50. "http/1.1"
  51. ],
  52. "session_ticket": true,
  53. "reuse_session": true,
  54. "plain_http_response": "",
  55. "fallback_addr": "127.0.0.1",
  56. "fallback_port": 2096,
  57. "fingerprint": ""
  58. },
  59. "tcp": {
  60. "no_delay": true,
  61. "keep_alive": true,
  62. "prefer_ipv4": false
  63. },
  64. "mux": {
  65. "enabled": true,
  66. "concurrency": 64,
  67. "idle_timeout": 60
  68. },
  69. "router": {
  70. "enabled": true,
  71. "bypass": [],
  72. "proxy": [],
  73. "block": [],
  74. "default_policy": "proxy",
  75. "domain_strategy": "as_is",
  76. "geoip": "/etc/trojan-go/geoip.dat",
  77. "geosite": "/etc/trojan-go/geosite.dat"
  78. },
  79. "websocket": {
  80. "enabled": true,
  81. "path": "/brody",
  82. "host": "$domain"
  83. },
  84. "shadowsocks": {
  85. "enabled": false,
  86. "method": "AES-128-GCM",
  87. "password": ""
  88. },
  89. "transport_plugin": {
  90. "enabled": false,
  91. "type": "",
  92. "command": "",
  93. "plugin_option": "",
  94. "arg": [],
  95. "env": []
  96. },
  97. "forward_proxy": {
  98. "enabled": false,
  99. "proxy_addr": "",
  100. "proxy_port": 0,
  101. "username": "",
  102. "password": ""
  103. },
  104. "mysql": {
  105. "enabled": false,
  106. "server_addr": "localhost",
  107. "server_port": 3306,
  108. "database": "",
  109. "username": "",
  110. "password": "",
  111. "check_rate": 60
  112. },
  113. "api": {
  114. "enabled": false,
  115. "api_addr": "",
  116. "api_port": 0,
  117. "ssl": {
  118. "enabled": false,
  119. "key": "",
  120. "cert": "",
  121. "verify_client": false,
  122. "client_cert": []
  123. }
  124. }
  125. }
  126. EOF
  127. cat <<EOF > /etc/systemd/system/trojan-go.service
  128. [Unit]
  129. Description=Trojan-Go
  130. Documentation=https://p4gefau1t.github.io/trojan-go/
  131. After=network.target nss-lookup.target
  132. [Service]
  133. User=root
  134. NoNewPrivileges=true
  135. ExecStart=/etc/trojan-go/trojan-go -config /etc/trojan-go/config.json
  136. Restart=on-failure
  137. RestartSec=10s
  138. LimitNOFILE=infinity
  139. [Install]
  140. WantedBy=multi-user.target
  141. EOF
  142. cat <<EOF > /etc/systemd/system/trojan-go@.service
  143. [Unit]
  144. Description=Trojan-Go
  145. Documentation=https://p4gefau1t.github.io/trojan-go/
  146. After=network.target nss-lookup.target
  147. [Service]
  148. User=root
  149. CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
  150. AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
  151. NoNewPrivileges=true
  152. ExecStart=/etc/trojan-go/trojan-go -config /etc/trojan-go/%i.json
  153. Restart=on-failure
  154. RestartSec=10s
  155. LimitNOFILE=infinity
  156. [Install]
  157. WantedBy=multi-user.target
  158. cat <<EOF > /etc/trojan-go/uuid.txt
  159. $uuid
  160. EOF
  161. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2096 -j ACCEPT
  162. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 2096 -j ACCEPT
  163. iptables-save >/etc/iptables.rules.v4
  164. netfilter-persistent save
  165. netfilter-persistent reload
  166. systemctl daemon-reload
  167. # Starting
  168. systemctl daemon-reload
  169. systemctl enable trojan-go.service
  170. systemctl start trojan-go
  171. systemctl enable trojan-go@.service
  172. systemctl start trojan-go