forked from buzzhub/lsyupdate
add lsy-frpc/
This commit is contained in:
parent
cbcbdfe3c2
commit
f23371b550
8
lsy-frpc/DEBIAN/control
Normal file
8
lsy-frpc/DEBIAN/control
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Package: lsyfrpc
|
||||||
|
Version: 1.0.2
|
||||||
|
Section: utils
|
||||||
|
Priority: optional
|
||||||
|
Architecture: arm64
|
||||||
|
Maintainer: Your Name <your_email@example.com>
|
||||||
|
Description: FRP client for remote access.
|
||||||
|
Depends: systemd (>= 237), libc6 (>= 2.27), curl, wget, systemd
|
||||||
11
lsy-frpc/DEBIAN/postinst
Executable file
11
lsy-frpc/DEBIAN/postinst
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PACKAGE_NAME="lsyfrpc"
|
||||||
|
PACKAGE_INSTALL_DIR=$(dpkg -L $PACKAGE_NAME | grep -m1 '^/')
|
||||||
|
|
||||||
|
cd /data/lsyfrpc
|
||||||
|
|
||||||
|
bash frp_install.sh
|
||||||
|
|
||||||
|
exit 0
|
||||||
10
lsy-frpc/build.sh
Normal file
10
lsy-frpc/build.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# sed -i 's/Architecture: amd64/Architecture: arm64/' ./lsyloader/DEBIAN/control
|
||||||
|
dpkg-deb --build ./ lsyfrpc.deb
|
||||||
|
ver=$(dpkg-deb --show lsyfrpc.deb|awk '{print $2}')
|
||||||
|
echo `sha256sum lsyfrpc.deb` >> "lsyfrpc$ver.debSign"
|
||||||
|
mv lsyfrpc.deb lsyfrpc$ver.deb
|
||||||
|
chmod 777 *.deb
|
||||||
|
mkdir -p arm64
|
||||||
|
mv *.deb ./arm64/
|
||||||
|
mv *.debSign ./arm64/
|
||||||
|
mv arm64 ../
|
||||||
89
lsy-frpc/data/lsyfrpc/frp_install.sh
Normal file
89
lsy-frpc/data/lsyfrpc/frp_install.sh
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
FRPC_FILE="/data/lsyfrpc/frpc"
|
||||||
|
FRPC_DIR="/data/lsyfrpc"
|
||||||
|
|
||||||
|
# 下载 FRPC(可保留原逻辑,不过在打包时可能已经包含了二进制文件,这里可按需调整)
|
||||||
|
function down_frpc() {
|
||||||
|
if [! -e "$FRPC_FILE" ]; then
|
||||||
|
echo "[INFO] Installing FRPC to '$FRPC_DIR'..."
|
||||||
|
mkdir -p "$FRPC_DIR"
|
||||||
|
wget "https://box.jxm.cool/download/frpc" -O "$FRPC_FILE"
|
||||||
|
chmod u+x "$FRPC_FILE"
|
||||||
|
else
|
||||||
|
echo "[INFO] FRPC 已安装,跳过下载。"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 安装和配置 FRPC(调整后的逻辑,先创建基础配置文件模板,后续首次运行再完善)
|
||||||
|
function install_frpc() {
|
||||||
|
mac_address=$(cat /sys/class/net/eth0/address)
|
||||||
|
echo "MAC Address: $mac_address"
|
||||||
|
new_mac_assress="$mac_address-v1"
|
||||||
|
|
||||||
|
# 创建或更新 FRPC 配置文件(先只写公共部分,端口相关留空,后续补全)
|
||||||
|
cat > "$FRPC_DIR/frpc.ini" <<EOF
|
||||||
|
[common]
|
||||||
|
server_addr = box.jxm.cool
|
||||||
|
server_port = 8000
|
||||||
|
token = 92098d16-1961-4bda-902b-e43e3d41d5a9
|
||||||
|
|
||||||
|
[$new_mac_assress]
|
||||||
|
type = tcp
|
||||||
|
local_ip = 127.0.0.1
|
||||||
|
local_port = 22
|
||||||
|
remote_port =
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 创建 systemd 服务文件(路径适配新目录)
|
||||||
|
cat > "/etc/systemd/system/lsyfrpc.service" <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=FRP Client
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStartPre=/bin/mkdir -p "$FRPC_DIR/var/run/frp/"
|
||||||
|
ExecStart="$FRPC_FILE" -c "$FRPC_DIR/frpc.ini"
|
||||||
|
PIDFile="$FRPC_DIR/var/run/frp/frpc.pid"
|
||||||
|
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5s
|
||||||
|
User=root
|
||||||
|
LimitNOFILE=65535
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo chmod 644 "$FRPC_DIR/frpc.ini"
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable lsyfrpc
|
||||||
|
sudo systemctl start lsyfrpc
|
||||||
|
|
||||||
|
# 首次运行时,获取端口并更新配置文件逻辑(可添加到脚本末尾,比如添加到一个新的函数里)
|
||||||
|
# 获取端口并更新配置文件
|
||||||
|
response=$(curl -s -X 'POST' \
|
||||||
|
'https://frp-box.jxm.cool/request_port/' \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H 'Authorization: Basic NTI0NzgxNTctMjY1Zi00ZGNjLWE0NDMtODE0YzJhMDMxYjhjOmM2ZDI3Nzc1LTJhMDgtNDkyZS1iMTExLTg5YWQzZDY5ZTliMA==' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{\"mac_address\": \"$mac_address\"}")
|
||||||
|
port=$(echo "$response" | grep -o '"port":[0-9]*' | awk -F: '{print $2}')
|
||||||
|
if [ -z "$port" ]; then
|
||||||
|
echo "[ERROR] Failed to get port from the response."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Port retrieved: $port"
|
||||||
|
# 更新配置文件中的 remote_port 字段
|
||||||
|
sed -i "s/remote_port = /remote_port = $port/" "$FRPC_DIR/frpc.ini"
|
||||||
|
sudo systemctl restart lsyfrpc
|
||||||
|
}
|
||||||
|
|
||||||
|
# 主函数,调用相关函数来完成安装等操作
|
||||||
|
main() {
|
||||||
|
down_frpc
|
||||||
|
install_frpc
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
BIN
lsy-frpc/data/lsyfrpc/frpc
Executable file
BIN
lsy-frpc/data/lsyfrpc/frpc
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user