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.

64 lines
1.3 KiB

5 months ago
#!/bin/bash
#!/bin/bash
# 创建一个目录用于存放虚拟环境
env_dir="myenv"
# 检查是否已经存在虚拟环境目录
if [ -d "$env_dir" ]; then
echo "虚拟环境目录 $env_dir 已存在,跳过创建步骤。"
else
# 创建虚拟环境
python3 -m venv $env_dir
echo "虚拟环境已创建在 $env_dir"
fi
# 激活虚拟环境
source $env_dir/bin/activate
# 检查是否成功激活虚拟环境
if [ "$VIRTUAL_ENV" != "" ]; then
echo "虚拟环境已激活"
else
echo "虚拟环境激活失败"
exit 1
fi
# 安装 paho-mqtt 库
5 months ago
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple paho-mqtt==2.1.0
5 months ago
# 验证安装
if python -c "import paho.mqtt.client" &> /dev/null; then
echo "paho-mqtt 安装成功"
else
echo "paho-mqtt 安装失败"
fi
# 提示如何退出虚拟环境
echo "要退出虚拟环境,请运行 'deactivate'"
5 months ago
# 运行第一关的mqtt_client.py
5 months ago
# 运行第一关的mqtt_client.py
nohup sudo $env_dir/bin/python3 smp_coder/mqtt_smp.py > log.txt 2>&1 &
if [ $? -eq 0 ]; then
echo "mqtt_smp.py 启动成功"
else
echo "mqtt_smp.py 启动失败"
fi
# 运行第二关的extur_smp.py
5 months ago
#nohup sudo $env_dir/bin/python3 smp_coder/extur_smp.py > logex.txt 2>&1 &
#if [ $? -eq 0 ]; then
# echo "extur_smp.py 启动成功"
#else
# echo "extur_smp.py 启动失败"
#fi
5 months ago
5 months ago