generate.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #!/bin/bash
  2. #################################
  3. # main domain #
  4. #################################
  5. export main_domain="your.domain.com" # Change this to the correct value
  6. export main_domain_crt="\/path\/to\/main\/domain\/fullchain.pem" # Change this to the correct value
  7. export main_domain_key="\/path\/to\/main\/domain\/privkey.pem" # Change this to the correct value
  8. #################################
  9. # behind cdn domain #
  10. #################################
  11. export cdn_domain="" # Change this to the correct value
  12. export cdn_domain_crt="\/path\/to\/cdn\/domain\/fullchain.pem" # Change this to the correct value
  13. export cdn_domain_key="\/path\/to\/cdn\/domain\/privkey.pem" # Change this to the correct value
  14. #################################
  15. # uuid/pass #
  16. #################################
  17. export myid=`xray uuid` # (optional) Let xray pick a random uuid or change it
  18. export mypass=`date | md5sum | cut -c -15` # (optional) Set a password or let script pick one at random
  19. #######################################################################################
  20. #######################################################################################
  21. ###### Do not change anything below this line unless you know what you're doing. ######
  22. #######################################################################################
  23. #######################################################################################
  24. #################################
  25. # fake data #
  26. #################################
  27. export fake_domain="example.com"
  28. export fake_cdn_domain="behindcdn.com"
  29. export fakepass="desdemona99"
  30. export fakeid="90e4903e-66a4-45f7-abda-fd5d5ed7f797"
  31. export fake_domain_crt_path="\/etc\/ssl\/example.com\/domain.pem"
  32. export fake_domain_key_path="\/etc\/ssl\/example.com\/domain-key.pem"
  33. export fake_cdn_domain_crt_path="\/etc\/ssl\/behindcdn.com\/domain.pem"
  34. export fake_cdn_domain_key_path="\/etc\/ssl\/behindcdn.com\/domain-key.pem"
  35. Help()
  36. {
  37. echo "*************************************************************************"
  38. echo "*************************************************************************"
  39. echo "Please read the contents of this file and change all the required fields."
  40. echo "*************************************************************************"
  41. echo "*************************************************************************"
  42. echo
  43. echo
  44. echo "Commands"
  45. echo
  46. echo "m Make and store the configs in result.txt."
  47. echo "r Revert all the changes."
  48. echo "q Print the qr codes of configs in terminal. Run this after running with -m."
  49. echo "b Print one base64 link for all configs in terminal. Run this after running with -m."
  50. echo
  51. echo
  52. echo "Usage: "
  53. echo
  54. echo " bash setup.sh <-command> "
  55. echo
  56. }
  57. Revert()
  58. {
  59. git restore client.configs/* server.jsonc nginx.conf
  60. }
  61. Make()
  62. {
  63. #################################
  64. # main domain #
  65. #################################
  66. sed -i "s/$fake_domain_crt_path/$main_domain_crt/g" server.jsonc client.configs/* nginx.conf
  67. sed -i "s/$fake_domain_key_path/$main_domain_key/g" server.jsonc client.configs/* nginx.conf
  68. sed -i "s/$fake_domain/$main_domain/g" server.jsonc client.configs/* nginx.conf
  69. #################################
  70. # behind cdn domain #
  71. #################################
  72. if [ "$cdn_domain" == "" ]; then
  73. echo "No domain behind cdn set. Removing related fields."
  74. sed -i "146 s/.$//" server.jsonc
  75. sed -i "147,152d" server.jsonc
  76. fi
  77. sed -i "s/$fake_cdn_domain_crt_path/$cdn_domain_crt/g" server.jsonc client.configs/* nginx.conf
  78. sed -i "s/$fake_cdn_domain_key_path/$cdn_domain_key/g" server.jsonc client.configs/* nginx.conf
  79. sed -i "s/$fake_cdn_domain/$cdn_domain/g" server.jsonc client.configs/* nginx.conf
  80. #################################
  81. # uuid/pass #
  82. #################################
  83. sed -i "s/$fakeid/$myid/g" server.jsonc client.configs/* nginx.conf
  84. sed -i "s/$fakepass/$mypass/g" server.jsonc client.configs/* nginx.conf
  85. #################################
  86. # configs #
  87. #################################
  88. rm result.txt
  89. touch result.txt
  90. #grep "| Trojan-TCP |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
  91. grep "| Trojan-WS |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
  92. grep "| Trojan-gRPC |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
  93. #grep "| Trojan-H2 |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
  94. #grep "| Vless-TCP |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
  95. grep "| Vless-WS |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
  96. grep "| Vless-gRPC |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
  97. #grep "| Vless-H2 |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
  98. #grep "| VMESS-TCP |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/vmess:\/\//" >> result.txt
  99. grep "| VMESS-WS |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
  100. grep "| VMESS-gRPC |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
  101. #grep "| VMESS-H2 |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
  102. echo >> result.txt
  103. }
  104. Print64()
  105. {
  106. cat result.txt | base64 -w 0
  107. echo
  108. }
  109. Printqr()
  110. {
  111. while read line; do
  112. export t=`echo $line | cut -c -2`
  113. if [ "$t" == "vm" ]; then
  114. echo $line | cut -c 9- | base64 -d | grep "\"ps\":" | sed -n -e 's/"ps": "//p' | sed -n -e 's/",//p' | sed -n -e 's/ *//p'
  115. curl qrcode.show -d $line
  116. else
  117. echo $line | sed -n -e 's/^.*#//p'
  118. curl qrcode.show -d $line
  119. fi
  120. done < result.txt
  121. }
  122. while getopts "mrqb" option; do
  123. case $option in
  124. r)
  125. Revert
  126. exit;;
  127. m)
  128. Make
  129. exit;;
  130. b)
  131. Print64
  132. exit;;
  133. q)
  134. Printqr
  135. exit;;
  136. \?)
  137. Help
  138. exit;;
  139. esac
  140. done
  141. Help