You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
software/deploy_p600_local.sh

80 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# =============================================================================
# P600 机载电脑 - 电脑端网页本地部署脚本
# 用法: P600 上执行: bash deploy_p600_local.sh
# 效果: 在 P600 上运行 Flask 服务,本地访问 http://192.168.1.14:5000
# 直接连接 P600 机载电脑的 rosbridge浏览器不拦截内网连接
# =============================================================================
set -e
echo "========================================="
echo " P600 智途投送电脑端本地部署"
echo "========================================="
echo ""
PROJECT_DIR="/opt/zhitu-p600"
# 创建项目目录
echo "📁 创建项目目录 ${PROJECT_DIR} ..."
mkdir -p ${PROJECT_DIR}
# 解压文件
echo "📦 解压文件..."
tar xzf zhitu-local-deploy.tar.gz -C ${PROJECT_DIR}
# 安装 Python 依赖
echo "🐍 安装 Python 依赖..."
cd ${PROJECT_DIR}/server
pip3 install flask flask-cors werkzeug 2>/dev/null || pip install flask flask-cors werkzeug 2>/dev/null || echo "⚠️ pip 安装失败,手动执行: pip install flask flask-cors"
# 创建 systemd 服务
echo "📝 创建系统服务 zhitu-p600.service ..."
cat > /etc/systemd/system/zhitu-p600.service << 'EOF'
[Unit]
Description=智途投送电脑端 - P600 本地服务
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/zhitu-p600/server
ExecStart=/usr/bin/python3 app.py
Restart=always
RestartSec=5
StandardOutput=append:/var/log/zhitu-p600.log
StandardError=append:/var/log/zhitu-p600.log
[Install]
WantedBy=multi-user.target
EOF
# 重载并启用服务
systemctl daemon-reload
systemctl enable zhitu-p600.service
# 启动服务
echo "🚀 启动服务..."
systemctl restart zhitu-p600.service
sleep 2
# 检查状态
echo ""
echo "📊 服务状态:"
systemctl status zhitu-p600.service --no-pager | head -10
echo ""
echo "========================================="
echo " ✅ 部署完成!"
echo "========================================="
echo ""
echo " 访问地址: http://192.168.1.14:5000"
echo " rosbridge: 本地自动连接 (无需 WebSocket 跨网)"
echo ""
echo " 管理命令:"
echo " 查看状态: sudo systemctl status zhitu-p600"
echo " 重启: sudo systemctl restart zhitu-p600"
echo " 查看日志: tail -f /var/log/zhitu-p600.log"
echo ""