#!/bin/bash

# 判断 python项目管理器 是否安装
if [ ! -d "/www/server/panel/plugin/pythonmamager" ]; then
        echo -e "PYTHON_MAMAGER_NOT_INSTALL"
        exit;
fi

# 判断 python3 是否安装
if [ ! -d "/www/server/python_manager/versions/3.7.9" ]; then
        echo -e "PYTHON_NOT_INSTALL"
        exit;   
fi

# receptor-s 配置
cd /opt/http-receptor-server-s && /www/server/python_manager/versions/3.7.*/bin/python3 -m venv _venv && source ./_venv/bin/activate && pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

# receptor-m 配置
cd /opt/http-receptor-server-m && /www/server/python_manager/versions/3.7.*/bin/python3 -m venv _venv && source ./_venv/bin/activate && pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

# record 配置
cd /opt/trade-record-service && /www/server/python_manager/versions/3.7.*/bin/python3 -m venv _venv && source ./_venv/bin/activate && pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

# ETCP_lane2 配置
cd /opt/etc-pay-controller-zx && /www/server/python_manager/versions/3.7.*/bin/python3 -m venv _venv && source ./_venv/bin/activate && pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

# receive-operate 配置
cd /opt/receive-operate && /www/server/python_manager/versions/3.7.*/bin/python3 -m venv _venv && source ./_venv/bin/activate && pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100

# 更新项目的配置
mkdir -p /opt/operate
wget --no-check-certificate -P /opt/operate https://file.tyxhetc.cn/update/update.py
cp -r /opt/receive-operate/_venv /opt/operate
mv /opt/operate/_venv /opt/operate/venv
