forked from buzzhub/lsyupdate
add_9100
This commit is contained in:
parent
21bd6a0fda
commit
ed9c8b83b0
@ -19,7 +19,8 @@ function down_frpc() {
|
|||||||
function install_frpc() {
|
function install_frpc() {
|
||||||
mac_address=$(cat /sys/class/net/eth0/address)
|
mac_address=$(cat /sys/class/net/eth0/address)
|
||||||
echo "MAC Address: $mac_address"
|
echo "MAC Address: $mac_address"
|
||||||
new_mac_assress="$mac_address-v1"
|
new_mac_address="$mac_address-v1"
|
||||||
|
new_mac_address_9100="$mac_address-v2"
|
||||||
|
|
||||||
# 创建或更新 FRPC 配置文件(先只写公共部分,端口相关留空,后续补全)
|
# 创建或更新 FRPC 配置文件(先只写公共部分,端口相关留空,后续补全)
|
||||||
cat > "$FRPC_DIR/frpc.ini" <<EOF
|
cat > "$FRPC_DIR/frpc.ini" <<EOF
|
||||||
@ -28,11 +29,17 @@ server_addr = box.jxm.cool
|
|||||||
server_port = 8000
|
server_port = 8000
|
||||||
token = 92098d16-1961-4bda-902b-e43e3d41d5a9
|
token = 92098d16-1961-4bda-902b-e43e3d41d5a9
|
||||||
|
|
||||||
[$new_mac_assress]
|
[$new_mac_address]
|
||||||
type = tcp
|
type = tcp
|
||||||
local_ip = 127.0.0.1
|
local_ip = 127.0.0.1
|
||||||
local_port = 22
|
local_port = 22
|
||||||
remote_port =
|
remote_port =
|
||||||
|
|
||||||
|
[$new_mac_address_9100]
|
||||||
|
type = tcp
|
||||||
|
local_ip = 127.0.0.1
|
||||||
|
local_port = 9100
|
||||||
|
remote_port =
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 创建 systemd 服务文件(路径适配新目录)
|
# 创建 systemd 服务文件(路径适配新目录)
|
||||||
@ -43,13 +50,9 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
# ExecStartPre=/bin/mkdir -p "$FRPC_DIR/var/"
|
|
||||||
# ExecStartPre=/bin/bash -c "$FRPC_DIR/check_config.sh &"
|
|
||||||
ExecStart="$FRPC_FILE" -c "$FRPC_DIR/frpc.ini"
|
ExecStart="$FRPC_FILE" -c "$FRPC_DIR/frpc.ini"
|
||||||
ExecStartPost=/bin/bash -c "$FRPC_DIR/check_config.sh &"
|
ExecStartPost=/bin/bash -c "$FRPC_DIR/check_config.sh &"
|
||||||
TimeoutSec=60
|
TimeoutSec=60
|
||||||
# PIDFile="$FRPC_DIR/frpc.pid"
|
|
||||||
|
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=60
|
RestartSec=60
|
||||||
User=root
|
User=root
|
||||||
@ -63,9 +66,7 @@ EOF
|
|||||||
sudo chmod 655 "$FRPC_DIR/check_config.sh"
|
sudo chmod 655 "$FRPC_DIR/check_config.sh"
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable lsyfrpc
|
sudo systemctl enable lsyfrpc
|
||||||
# sudo systemctl start lsyfrpc
|
|
||||||
|
|
||||||
# 首次运行时,获取端口并更新配置文件逻辑(可添加到脚本末尾,比如添加到一个新的函数里)
|
|
||||||
# 获取端口并更新配置文件
|
# 获取端口并更新配置文件
|
||||||
response=$(curl -s -X 'POST' \
|
response=$(curl -s -X 'POST' \
|
||||||
'https://frp-box.jxm.cool/request_port/' \
|
'https://frp-box.jxm.cool/request_port/' \
|
||||||
@ -79,8 +80,14 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Port retrieved: $port"
|
echo "Port retrieved: $port"
|
||||||
|
|
||||||
|
# 计算 9100 端口的远程端口
|
||||||
|
port_9100=$((port + 10000))
|
||||||
|
|
||||||
# 更新配置文件中的 remote_port 字段
|
# 更新配置文件中的 remote_port 字段
|
||||||
sed -i "s/remote_port = /remote_port = $port/" "$FRPC_DIR/frpc.ini"
|
sed -i "s/remote_port = /remote_port = $port/" "$FRPC_DIR/frpc.ini"
|
||||||
|
sed -i "s/remote_port = /remote_port = $port_9100/" "$FRPC_DIR/frpc.ini"
|
||||||
|
|
||||||
sudo systemctl start lsyfrpc
|
sudo systemctl start lsyfrpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user