forked from buzzhub/lsyupdate
1
This commit is contained in:
parent
1ad2ceda65
commit
7b25144e2e
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# FRPC 配置目录和文件路径
|
# FRPC 配置目录和文件路径
|
||||||
FLAG_FILE="/tmp/lsyfrpc_check_config_running"
|
LOCK_FILE="/tmp/lsyfrpc_check_config_running.lock"
|
||||||
FRPC_FILE="/data/lsyfrpc/frpc"
|
FRPC_FILE="/data/lsyfrpc/frpc"
|
||||||
FRPC_DIR="/data/lsyfrpc"
|
FRPC_DIR="/data/lsyfrpc"
|
||||||
CONFIG_FILE="$FRPC_DIR/frpc.ini"
|
CONFIG_FILE="$FRPC_DIR/frpc.ini"
|
||||||
@ -12,7 +12,7 @@ function get_cloud_config() {
|
|||||||
echo "MAC Address: $mac_address"
|
echo "MAC Address: $mac_address"
|
||||||
|
|
||||||
# 尝试获取云端端口,最多重试 5 次
|
# 尝试获取云端端口,最多重试 5 次
|
||||||
retries=5
|
retries=1
|
||||||
for ((i=1; i<=retries; i++)); do
|
for ((i=1; i<=retries; i++)); do
|
||||||
response=$(curl -s -X 'POST' \
|
response=$(curl -s -X 'POST' \
|
||||||
'https://frp-box.jxm.cool/request_port/' \
|
'https://frp-box.jxm.cool/request_port/' \
|
||||||
@ -58,7 +58,6 @@ function check_config() {
|
|||||||
# 比较配置文件中的 MAC 地址和端口是否与云端匹配
|
# 比较配置文件中的 MAC 地址和端口是否与云端匹配
|
||||||
if [ "$current_mac_address" != "$cloud_mac_address" ] || [ "$current_port" != "$cloud_port" ]; then
|
if [ "$current_mac_address" != "$cloud_mac_address" ] || [ "$current_port" != "$cloud_port" ]; then
|
||||||
echo "[INFO] Configuration mismatch detected. Re-running install.sh..."
|
echo "[INFO] Configuration mismatch detected. Re-running install.sh..."
|
||||||
# sudo /bin/bash $FRPC_DIR/frp_install.sh
|
|
||||||
cat > "$FRPC_DIR/frpc.ini" <<EOF
|
cat > "$FRPC_DIR/frpc.ini" <<EOF
|
||||||
[common]
|
[common]
|
||||||
server_addr = box.jxm.cool
|
server_addr = box.jxm.cool
|
||||||
@ -81,6 +80,19 @@ EOF
|
|||||||
|
|
||||||
# 主函数,获取云端配置并检查配置
|
# 主函数,获取云端配置并检查配置
|
||||||
main() {
|
main() {
|
||||||
|
# 检查锁文件
|
||||||
|
if [ -f "$LOCK_FILE" ]; then
|
||||||
|
echo "[INFO] Lock file exists. Script is already running."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建锁文件
|
||||||
|
touch "$LOCK_FILE"
|
||||||
|
|
||||||
|
# 设置脚本在退出时删除锁文件
|
||||||
|
trap "rm -f $LOCK_FILE" EXIT
|
||||||
|
|
||||||
|
# 主逻辑
|
||||||
get_cloud_config
|
get_cloud_config
|
||||||
check_config "$cloud_port" "$cloud_mac_address"
|
check_config "$cloud_port" "$cloud_mac_address"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user