#!/bin/bash

# 添加项目
cp -r /opt/etc-pay-controller-zx /opt/etc-pay-controller-zx-"$1"
sed -i 's/]/, {"pjname": "ETCP-lane-'$1'", "version": "3.7.9", "rfile": "\/opt\/etc-pay-controller-zx-'$1'\/run.py", "path": "\/opt\/etc-pay-controller-zx-'$1'\/", "vpath": "\/opt\/etc-pay-controller-zx-'$1'\/\/*_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


# 添加 supervisor
cp /www/server/panel/plugin/supervisor/profile/ETCP-lane2.ini /www/server/panel/plugin/supervisor/profile/ETCP-lane-"$1".ini
sed -i "s/ETCP-lane2/ETCP-lane-$1/g" /www/server/panel/plugin/supervisor/profile/ETCP-lane-"$1".ini
sed -i "s/etc-pay-controller-zx/etc-pay-controller-zx-$1/g" /www/server/panel/plugin/supervisor/profile/ETCP-lane-"$1".ini

# 重启 supervisor
/www/server/panel/pyenv/bin/supervisorctl reload
