#!/bin/bash

mkdir -p /var/log/etc-controller
wget --no-check-certificate -P /opt https://file.tyxhetc.cn/etc-pay-controller-zx.zip
unzip -d /opt /opt/etc-pay-controller-zx.zip
rm -rf /opt/etc-pay-controller-zx.zip

# ETCP_lane2 配置
cd /opt/etc-pay-controller-zx && /www/server/python_manager/versions/3.*.*/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

sed -i 's/]/, {"pjname": "ETCP_lane2", "version": "3.7.9", "rfile": "\/opt\/etc-pay-controller-zx\/run.py", "path": "\/opt\/etc-pay-controller-zx\/", "vpath": "\/opt\/etc-pay-controller-zx\/\/*_venv", "status": "0", "port": "", "rtype": "python", "proxy": "", "framework": "python", "auto_start": "0", "user": "root", "parm": "", "run": "run:app", "worker": "worker_class = geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "cpu": 0, "mem": 0}]/g' /www/server/panel/plugin/pythonmamager/config.json
sed -i "s/worker_class = geventwebsocket.gunicorn.workers.GeventWebSocketWorker/worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'/g" /www/server/panel/plugin/pythonmamager/config.json

wget --no-check-certificate -P /www/server/panel/plugin/supervisor/profile https://file.tyxhetc.cn/ETCP-lane2.ini