feat: 一键安装脚本 install.sh,自动识别架构
This commit is contained in:
parent
24b9400767
commit
e411385718
@ -25,28 +25,15 @@ bash scripts/package.sh
|
|||||||
# 传到设备
|
# 传到设备
|
||||||
scp safesight-control-*.tar.gz user@server:/tmp/
|
scp safesight-control-*.tar.gz user@server:/tmp/
|
||||||
|
|
||||||
# 解压
|
# 解压并一键安装
|
||||||
cd /tmp && tar -xzf safesight-control-*.tar.gz
|
cd /tmp && tar -xzf safesight-control-*.tar.gz
|
||||||
cd safesight-control-*
|
cd safesight-control-*
|
||||||
|
sudo bash install.sh
|
||||||
# 安装
|
|
||||||
sudo mkdir -p /opt/safesightd/{bin,config,data}
|
|
||||||
sudo cp safesightd-linux-arm64 /opt/safesightd/bin/safesightd
|
|
||||||
sudo chmod +x /opt/safesightd/bin/safesightd
|
|
||||||
sudo cp safesightd.json.example /opt/safesightd/config/safesightd.json
|
|
||||||
sudo cp -r configs /opt/safesightd/
|
|
||||||
sudo cp -r tools /opt/safesightd/
|
|
||||||
sudo cp -r scripts /opt/safesightd/
|
|
||||||
|
|
||||||
# 安装服务
|
|
||||||
sudo cp safesightd.service /etc/systemd/system/
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable --now safesightd
|
|
||||||
|
|
||||||
# 首次启动自动导入种子数据,无需手动操作
|
|
||||||
```
|
```
|
||||||
|
|
||||||
AMD64 部署同上,二进制改为 `safesightd-linux-amd64`。
|
AMD64 部署同上,`install.sh` 自动识别架构。
|
||||||
|
|
||||||
|
首次启动自动导入种子数据,无需手动操作。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
51
scripts/deploy/install.sh
Normal file
51
scripts/deploy/install.sh
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# SafeSight Control 一键安装脚本
|
||||||
|
# 用法: sudo bash install.sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "请用 sudo 运行"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
INSTALL_DIR="${1:-/opt/safesightd}"
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
echo "========== SafeSight Control 安装 =========="
|
||||||
|
echo "安装目录: $INSTALL_DIR"
|
||||||
|
|
||||||
|
# 选二进制
|
||||||
|
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||||
|
BIN="safesightd-linux-arm64"
|
||||||
|
elif [ "$ARCH" = "x86_64" ]; then
|
||||||
|
BIN="safesightd-linux-amd64"
|
||||||
|
else
|
||||||
|
echo "不支持的架构: $ARCH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建目录
|
||||||
|
mkdir -p "$INSTALL_DIR"/{bin,config,data}
|
||||||
|
|
||||||
|
# 复制文件
|
||||||
|
cp "$SCRIPT_DIR/$BIN" "$INSTALL_DIR/bin/safesightd"
|
||||||
|
chmod +x "$INSTALL_DIR/bin/safesightd"
|
||||||
|
|
||||||
|
[ -f "$SCRIPT_DIR/safesightd.json.example" ] && cp "$SCRIPT_DIR/safesightd.json.example" "$INSTALL_DIR/config/safesightd.json"
|
||||||
|
[ -d "$SCRIPT_DIR/configs" ] && cp -r "$SCRIPT_DIR/configs" "$INSTALL_DIR/"
|
||||||
|
[ -d "$SCRIPT_DIR/tools" ] && cp -r "$SCRIPT_DIR/tools" "$INSTALL_DIR/"
|
||||||
|
[ -d "$SCRIPT_DIR/scripts" ] && cp -r "$SCRIPT_DIR/scripts" "$INSTALL_DIR/"
|
||||||
|
[ -d "$SCRIPT_DIR/deps" ] && cp -r "$SCRIPT_DIR/deps" "$INSTALL_DIR/"
|
||||||
|
|
||||||
|
# 安装服务
|
||||||
|
cp "$SCRIPT_DIR/safesightd.service" /etc/systemd/system/
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now safesightd
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "========== 安装完成 =========="
|
||||||
|
echo "服务状态:"
|
||||||
|
systemctl status safesightd --no-pager -l
|
||||||
|
echo ""
|
||||||
|
echo "打开 http://$(hostname -I | awk '{print $1}'):18080"
|
||||||
@ -25,6 +25,7 @@ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o "$BUILD_DIR/s
|
|||||||
echo "[2/6] 部署文件..."
|
echo "[2/6] 部署文件..."
|
||||||
mkdir -p "$BUILD_DIR/scripts"
|
mkdir -p "$BUILD_DIR/scripts"
|
||||||
cp scripts/deploy/safesightd.service "$BUILD_DIR/"
|
cp scripts/deploy/safesightd.service "$BUILD_DIR/"
|
||||||
|
cp scripts/deploy/install.sh "$BUILD_DIR/"
|
||||||
cp scripts/deploy/safesightd "$BUILD_DIR/" 2>/dev/null || true
|
cp scripts/deploy/safesightd "$BUILD_DIR/" 2>/dev/null || true
|
||||||
cp scripts/deploy/import-assets.py "$BUILD_DIR/scripts/" 2>/dev/null || true
|
cp scripts/deploy/import-assets.py "$BUILD_DIR/scripts/" 2>/dev/null || true
|
||||||
cp scripts/deploy/register-face-gallery.py "$BUILD_DIR/scripts/" 2>/dev/null || true
|
cp scripts/deploy/register-face-gallery.py "$BUILD_DIR/scripts/" 2>/dev/null || true
|
||||||
@ -79,29 +80,17 @@ cat > "$BUILD_DIR/README.txt" << 'EOF'
|
|||||||
SafeSight Control 离线部署包
|
SafeSight Control 离线部署包
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
快速部署(ARM64):
|
一键安装:
|
||||||
sudo mkdir -p /opt/safesightd/{bin,config,data,scripts,tools}
|
sudo bash install.sh
|
||||||
sudo cp safesightd-linux-arm64 /opt/safesightd/bin/safesightd
|
|
||||||
sudo chmod +x /opt/safesightd/bin/safesightd
|
|
||||||
sudo cp safesightd.json.example /opt/safesightd/config/safesightd.json
|
|
||||||
sudo cp -r configs /opt/safesightd/
|
|
||||||
sudo cp -r tools /opt/safesightd/
|
|
||||||
sudo cp -r scripts /opt/safesightd/
|
|
||||||
sudo cp safesightd.service /etc/systemd/system/
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable --now safesightd
|
|
||||||
|
|
||||||
初始化(首次部署必做):
|
|
||||||
sudo python3 /opt/safesightd/scripts/import-assets.py /opt/safesightd/configs
|
|
||||||
|
|
||||||
安装人脸库构建依赖(离线):
|
|
||||||
sudo pip3 install deps/*.whl
|
|
||||||
|
|
||||||
人脸库注册(如已有 face_gallery.db):
|
|
||||||
sudo cp face_gallery.db /opt/safesightd/resources/standard_resources/face_gallery/
|
|
||||||
sudo python3 /opt/safesightd/scripts/register-face-gallery.py
|
|
||||||
|
|
||||||
打开 http://<IP>:18080
|
打开 http://<IP>:18080
|
||||||
|
|
||||||
|
---
|
||||||
|
首次启动自动导入模板/场景/覆盖层,无需手动操作。
|
||||||
|
|
||||||
|
人脸库构建(离线环境):
|
||||||
|
sudo pip3 install deps/*.whl # 安装 Python 依赖
|
||||||
|
curl -X POST http://localhost:18080/face-gallery/build # 触发构建
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# ── 打包 ──
|
# ── 打包 ──
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user