31 lines
825 B
Bash
31 lines
825 B
Bash
|
|
#!/bin/bash
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "=== CBPOA Backend Deployment ==="
|
||
|
|
|
||
|
|
INSTALL_DIR=/opt/cbpoa/backend
|
||
|
|
|
||
|
|
# Copy backend files
|
||
|
|
sudo mkdir -p $INSTALL_DIR
|
||
|
|
sudo cp -r . $INSTALL_DIR/
|
||
|
|
|
||
|
|
# Fix venv shebangs (hardcoded to build machine path)
|
||
|
|
echo "Fixing venv shebangs..."
|
||
|
|
VENV_PYTHON="$INSTALL_DIR/venv/bin/python3"
|
||
|
|
find "$INSTALL_DIR/venv/bin" -type f -exec grep -l '#!/home/akiba' {} \; 2>/dev/null | while read f; do
|
||
|
|
sudo sed -i "s|#!/home/akiba/CA/backend/venv/bin/python3|#!$VENV_PYTHON|g" "$f"
|
||
|
|
done
|
||
|
|
|
||
|
|
# Fix permissions
|
||
|
|
sudo chown -R www-data:www-data $INSTALL_DIR
|
||
|
|
|
||
|
|
# Install systemd service
|
||
|
|
sudo cp cbpoa-backend.service /etc/systemd/system/
|
||
|
|
sudo systemctl daemon-reload
|
||
|
|
sudo systemctl enable cbpoa-backend
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "=== Done! Start with: ==="
|
||
|
|
echo " sudo systemctl start cbpoa-backend"
|
||
|
|
echo " curl http://localhost:8000/docs"
|