This commit is contained in:
vincent 2024-02-28 22:00:27 +08:00
parent bd43db3a6c
commit cf61ead0ab
6 changed files with 16 additions and 19 deletions

View File

@ -7,8 +7,6 @@
- docker-compose
- jq - 用于查看json文件, 提取json文件信息. 编辑json文件
- qrencode - 用于生成二维码
- openssl - 生成密钥
- uuidgen - 生成uuid
## 启动和关闭
生成并设置密钥和uuid

View File

@ -1,21 +1,13 @@
#!/bin/bash
# Generate private key
private_key=$(openssl genpkey -algorithm X25519)
# Extract public key from private key
public_key=$(echo "$private_key" | openssl pkey -pubout)
public_key=$(echo "$public_key" | sed -n '2p' | tr -d '\n')
private_key=$(echo "$private_key" | sed -n '2p' | tr -d '\n')
# Save keys to key.txt
echo "Private_key: $private_key" > ../conf/key.txt
echo "Public_key: $public_key" >> ../conf/key.txt
xray x25519 > ../conf/key.txt
echo "success save keys to key.txt"
# update config.json
private_key = $(grep "Public key" ../conf/key.txt | awk -F ': ' '{print $2}'
# # update config.json
jq ".inbounds[0].streamSettings.realitySettings.privateKey=\"$private_key\"" ../conf/config.json > ../conf/config_temp.json
mv ../conf/config_temp.json ../conf/config.json
echo "success updated private key to config.json"
echo "生成和设置密钥成功."

View File

@ -1,5 +1,8 @@
#!/bin/bash
# 安装xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
# 生成uui, 写入到config.json文件
bash ./update_uuid.sh

4
bin/remove_xray.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Remove Xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove

View File

@ -1,7 +1,7 @@
#!/bin/bash
# 生成 UUID
uuid=$(uuidgen -r 4)
uuid=$(xray uuid)
# 使用 jq 修改 JSON 文件
jq ".inbounds[0].settings.clients[0].id=\"$uuid\"" ../conf/config.json > ../conf/config.json_tmp
@ -10,6 +10,6 @@ jq ".inbounds[0].settings.clients[0].id=\"$uuid\"" ../conf/config.json > ../conf
mv ../conf/config.json_tmp ../conf/config.json
# 验证结果
echo "UUID 已更新为: $uuid"
echo "设置UUID成功."

View File

@ -1,2 +1,2 @@
Public_key:
Private_key:
Private key: KJ42elMcVqM1b0-5Ny3iCUZVlvelibWKnGoF1kdklig
Public key: 0hBmzH75m67yWOp6z7Z67WFHT7gJ6o3Nql5Jc5nC6WU