|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
RED='\033[0;31m' |
|
|
GREEN='\033[0;32m' |
|
|
YELLOW='\033[1;33m' |
|
|
BLUE='\033[0;34m' |
|
|
NC='\033[0m' |
|
|
|
|
|
echo -e "${BLUE}π Phase 2 Cross-Domain Integration Deployment${NC}" |
|
|
echo "==============================================================" |
|
|
|
|
|
|
|
|
if [ ! -d "commsops" ]; then |
|
|
echo -e "${RED}β Must run from signalcore directory${NC}" |
|
|
echo "Current directory: $(pwd)" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Checking Python environment...${NC}" |
|
|
if ! command -v python3 &> /dev/null; then |
|
|
echo -e "${RED}β Python3 not found${NC}" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
python_version=$(python3 --version) |
|
|
echo -e "${GREEN}β
Python version: ${python_version}${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π¦ Checking Python dependencies...${NC}" |
|
|
required_packages=("numpy" "asyncio" "dataclasses") |
|
|
|
|
|
for package in "${required_packages[@]}"; do |
|
|
if ! python3 -c "import $package" 2>/dev/null; then |
|
|
echo -e "${RED}β Missing required package: $package${NC}" |
|
|
echo "Install with: pip3 install $package" |
|
|
exit 1 |
|
|
fi |
|
|
echo -e "${GREEN}β
Package available: $package${NC}" |
|
|
done |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Testing Neuromorphic Security System...${NC}" |
|
|
cd commsops |
|
|
|
|
|
if ! python3 neuromorphic_security.py; then |
|
|
echo -e "${RED}β Neuromorphic security test failed${NC}" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
echo -e "${GREEN}β
Neuromorphic security system test passed${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Testing DataOps Integration...${NC}" |
|
|
|
|
|
if ! python3 dataops_integration.py; then |
|
|
echo -e "${RED}β DataOps integration test failed${NC}" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
echo -e "${GREEN}β
DataOps integration test passed${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Creating production service files...${NC}" |
|
|
|
|
|
|
|
|
cat > neuromorphic-security.service << 'EOF' |
|
|
[Unit] |
|
|
Description=CommsOps Neuromorphic Security Service |
|
|
After=network.target |
|
|
|
|
|
[Service] |
|
|
Type=simple |
|
|
User=root |
|
|
WorkingDirectory=/data/adaptai/platform/signalcore/commsops |
|
|
ExecStart=/usr/bin/python3 /data/adaptai/platform/signalcore/commsops/neuromorphic_security_service.py |
|
|
Restart=always |
|
|
RestartSec=5 |
|
|
Environment=PYTHONUNBUFFERED=1 |
|
|
|
|
|
[Install] |
|
|
WantedBy=multi-user.target |
|
|
EOF |
|
|
|
|
|
echo -e "${GREEN}β
Neuromorphic security service file created${NC}" |
|
|
|
|
|
|
|
|
cat > dataops-integration.service << 'EOF' |
|
|
[Unit] |
|
|
Description=CommsOps DataOps Integration Service |
|
|
After=network.target neuromorphic-security.service |
|
|
|
|
|
[Service] |
|
|
Type=simple |
|
|
User=root |
|
|
WorkingDirectory=/data/adaptai/platform/signalcore/commsops |
|
|
ExecStart=/usr/bin/python3 /data/adaptai/platform/signalcore/commsops/dataops_integration_service.py |
|
|
Restart=always |
|
|
RestartSec=5 |
|
|
Environment=PYTHONUNBUFFERED=1 |
|
|
|
|
|
[Install] |
|
|
WantedBy=multi-user.target |
|
|
EOF |
|
|
|
|
|
echo -e "${GREEN}β
DataOps integration service file created${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Creating service wrapper scripts...${NC}" |
|
|
|
|
|
|
|
|
cat > neuromorphic_security_service.py << 'EOF' |
|
|
|
|
|
""" |
|
|
Neuromorphic Security Service Wrapper |
|
|
Production service for cross-domain security scanning |
|
|
""" |
|
|
|
|
|
import asyncio |
|
|
import signal |
|
|
import sys |
|
|
from neuromorphic_security import NeuromorphicSecurityAPI |
|
|
|
|
|
class SecurityService: |
|
|
def __init__(self): |
|
|
self.api = NeuromorphicSecurityAPI() |
|
|
self.running = True |
|
|
|
|
|
async def run_service(self): |
|
|
"""Main service loop""" |
|
|
print("π Neuromorphic Security Service starting...") |
|
|
|
|
|
|
|
|
print("π§ Initializing neuromorphic security patterns...") |
|
|
|
|
|
|
|
|
while self.running: |
|
|
try: |
|
|
|
|
|
await asyncio.sleep(1) |
|
|
|
|
|
|
|
|
if int(asyncio.get_event_loop().time()) % 10 == 0: |
|
|
metrics = await self.api.get_security_metrics() |
|
|
print(f"π Service heartbeat: {metrics['total_messages_scanned']} messages scanned") |
|
|
|
|
|
except asyncio.CancelledError: |
|
|
break |
|
|
except Exception as e: |
|
|
print(f"β οΈ Service error: {e}") |
|
|
await asyncio.sleep(5) |
|
|
|
|
|
def shutdown(self): |
|
|
"""Graceful shutdown""" |
|
|
print("π Shutting down neuromorphic security service...") |
|
|
self.running = False |
|
|
|
|
|
async def main(): |
|
|
service = SecurityService() |
|
|
|
|
|
|
|
|
def signal_handler(sig, frame): |
|
|
service.shutdown() |
|
|
|
|
|
signal.signal(signal.SIGINT, signal_handler) |
|
|
signal.signal(signal.SIGTERM, signal_handler) |
|
|
|
|
|
try: |
|
|
await service.run_service() |
|
|
except KeyboardInterrupt: |
|
|
service.shutdown() |
|
|
finally: |
|
|
print("β
Neuromorphic Security Service stopped") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
asyncio.run(main()) |
|
|
EOF |
|
|
|
|
|
chmod +x neuromorphic_security_service.py |
|
|
|
|
|
echo -e "${GREEN}β
Neuromorphic security service wrapper created${NC}" |
|
|
|
|
|
|
|
|
cat > dataops_integration_service.py << 'EOF' |
|
|
|
|
|
""" |
|
|
DataOps Integration Service Wrapper |
|
|
Production service for cross-domain data operations |
|
|
""" |
|
|
|
|
|
import asyncio |
|
|
import signal |
|
|
import sys |
|
|
from dataops_integration import DataOpsIntegration, create_dataops_integration |
|
|
|
|
|
class DataOpsService: |
|
|
def __init__(self): |
|
|
self.integration = create_dataops_integration() |
|
|
self.running = True |
|
|
|
|
|
async def run_service(self): |
|
|
"""Main service loop""" |
|
|
print("π DataOps Integration Service starting...") |
|
|
|
|
|
|
|
|
print("π§ Initializing DataOps integration...") |
|
|
|
|
|
|
|
|
while self.running: |
|
|
try: |
|
|
|
|
|
await asyncio.sleep(1) |
|
|
|
|
|
|
|
|
if int(asyncio.get_event_loop().time()) % 15 == 0: |
|
|
metrics = await self.integration.get_performance_metrics() |
|
|
print(f"π Service heartbeat: {metrics['integration_metrics']['total_operations']} operations processed") |
|
|
|
|
|
except asyncio.CancelledError: |
|
|
break |
|
|
except Exception as e: |
|
|
print(f"β οΈ Service error: {e}") |
|
|
await asyncio.sleep(5) |
|
|
|
|
|
def shutdown(self): |
|
|
"""Graceful shutdown""" |
|
|
print("π Shutting down DataOps integration service...") |
|
|
self.running = False |
|
|
|
|
|
async def main(): |
|
|
service = DataOpsService() |
|
|
|
|
|
|
|
|
def signal_handler(sig, frame): |
|
|
service.shutdown() |
|
|
|
|
|
signal.signal(signal.SIGINT, signal_handler) |
|
|
signal.signal(signal.SIGTERM, signal_handler) |
|
|
|
|
|
try: |
|
|
await service.run_service() |
|
|
except KeyboardInterrupt: |
|
|
service.shutdown() |
|
|
finally: |
|
|
print("β
DataOps Integration Service stopped") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
asyncio.run(main()) |
|
|
EOF |
|
|
|
|
|
chmod +x dataops_integration_service.py |
|
|
|
|
|
echo -e "${GREEN}β
DataOps integration service wrapper created${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Installing service files...${NC}" |
|
|
|
|
|
if [ -d "/etc/systemd/system" ]; then |
|
|
sudo cp neuromorphic-security.service /etc/systemd/system/ |
|
|
sudo cp dataops-integration.service /etc/systemd/system/ |
|
|
|
|
|
echo -e "${GREEN}β
Service files installed to /etc/systemd/system/${NC}" |
|
|
|
|
|
|
|
|
sudo systemctl daemon-reload |
|
|
|
|
|
echo -e "${YELLOW}βοΈ Enabling services...${NC}" |
|
|
sudo systemctl enable neuromorphic-security.service |
|
|
sudo systemctl enable dataops-integration.service |
|
|
|
|
|
echo -e "${GREEN}β
Services enabled${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Starting services...${NC}" |
|
|
sudo systemctl start neuromorphic-security.service |
|
|
sudo systemctl start dataops-integration.service |
|
|
|
|
|
echo -e "${GREEN}β
Services started successfully${NC}" |
|
|
|
|
|
|
|
|
echo -e "${YELLOW}π Service status:${NC}" |
|
|
sudo systemctl status neuromorphic-security.service --no-pager -l |
|
|
echo "" |
|
|
sudo systemctl status dataops-integration.service --no-pager -l |
|
|
|
|
|
else |
|
|
echo -e "${YELLOW}β οΈ Systemd directory not available, manual deployment required${NC}" |
|
|
echo "Service files have been created in current directory:" |
|
|
echo " - neuromorphic-security.service" |
|
|
echo " - dataops-integration.service" |
|
|
echo " - neuromorphic_security_service.py" |
|
|
echo " - dataops_integration_service.py" |
|
|
echo "" |
|
|
echo "Manual deployment commands:" |
|
|
echo " sudo cp *.service /etc/systemd/system/" |
|
|
echo " sudo systemctl daemon-reload" |
|
|
echo " sudo systemctl enable --now neuromorphic-security.service" |
|
|
echo " sudo systemctl enable --now dataops-integration.service" |
|
|
fi |
|
|
|
|
|
|
|
|
cat > verify_deployment.sh << 'EOF' |
|
|
|
|
|
|
|
|
|
|
|
echo "π Verifying Phase 2 Deployment..." |
|
|
|
|
|
|
|
|
if systemctl is-active --quiet neuromorphic-security.service; then |
|
|
echo "β
Neuromorphic Security Service: ACTIVE" |
|
|
else |
|
|
echo "β Neuromorphic Security Service: INACTIVE" |
|
|
fi |
|
|
|
|
|
if systemctl is-active --quiet dataops-integration.service; then |
|
|
echo "β
DataOps Integration Service: ACTIVE" |
|
|
else |
|
|
echo "β DataOps Integration Service: INACTIVE" |
|
|
fi |
|
|
|
|
|
|
|
|
echo "π§ͺ Testing functionality..." |
|
|
cd /data/adaptai/platform/signalcore/commsops |
|
|
|
|
|
if python3 -c " |
|
|
import asyncio |
|
|
from neuromorphic_security import NeuromorphicSecurityAPI |
|
|
|
|
|
async def test(): |
|
|
api = NeuromorphicSecurityAPI() |
|
|
result = await api.scan_message(b'test message', 'data_ops') |
|
|
print(f'Security scan test: {result.approved}') |
|
|
return result.approved |
|
|
|
|
|
result = asyncio.run(test()) |
|
|
print(f'β
Security scan test completed: {result}') |
|
|
"; then |
|
|
echo "β
Security functionality verified" |
|
|
else |
|
|
echo "β Security functionality test failed" |
|
|
fi |
|
|
|
|
|
echo "π Deployment verification complete!" |
|
|
EOF |
|
|
|
|
|
chmod +x verify_deployment.sh |
|
|
|
|
|
echo -e "${GREEN}β
Deployment verification script created${NC}" |
|
|
|
|
|
|
|
|
echo "" |
|
|
echo -e "${BLUE}π Phase 2 Deployment Complete!${NC}" |
|
|
echo "==============================================================" |
|
|
echo "Services deployed:" |
|
|
echo " - neuromorphic-security.service (Neuromorphic Security)" |
|
|
echo " - dataops-integration.service (DataOps Integration)" |
|
|
echo "" |
|
|
echo "Next steps:" |
|
|
echo " 1. Run verification: ./verify_deployment.sh" |
|
|
echo " 2. Check logs: journalctl -u neuromorphic-security.service -f" |
|
|
echo " 3. Monitor performance: watch systemctl status dataops-integration.service" |
|
|
echo " 4. Integrate with monitoring dashboard" |
|
|
echo "" |
|
|
echo -e "${GREEN}π Phase 2 Cross-Domain Integration is now LIVE!${NC}" |