Newer Older
57 lines | 1.653kb
Bogdan Timofte authored 2 weeks ago
1
#!/bin/bash
2

            
3
# autoSMART Schema v2 — Deploy to Tapia (secondary node)
4
# Date: 2026-05-20
5
# Copies updated collectors and restarts service
6

            
7
set -e
8

            
9
TAPIA_IP="192.168.2.93"
10
TAPIA_USER="root"
11
TARGET_DIR="/opt/autoSMART"
12
PROJECT_DIR="$(dirname "$(dirname "$0")")"
13

            
14
echo "🚀 Deploying autoSMART collectors to tapia ($TAPIA_IP)..."
15
echo ""
16

            
17
# 1. Copy updated scripts
18
echo "📦 Copying updated scripts..."
19
scp -q "$PROJECT_DIR/scripts/smart-collector-daemon.pl" "$TAPIA_USER@$TAPIA_IP:$TARGET_DIR/scripts/"
20
scp -q "$PROJECT_DIR/lib/SmartCollector.pm" "$TAPIA_USER@$TAPIA_IP:$TARGET_DIR/lib/"
21
echo "✅ Scripts copied"
22
echo ""
23

            
24
# 2. Stop service on tapia
25
echo "🛑 Stopping autosmart service on tapia..."
26
ssh "$TAPIA_USER@$TAPIA_IP" "systemctl stop autosmart" || true
27
sleep 2
28
echo "✅ Service stopped"
29
echo ""
30

            
31
# 3. Restart service
32
echo "🚀 Starting autosmart service on tapia..."
33
ssh "$TAPIA_USER@$TAPIA_IP" "systemctl start autosmart"
34
sleep 3
35
echo "✅ Service started"
36
echo ""
37

            
38
# 4. Verify service is running
39
echo "🔍 Verifying service status..."
40
if ssh "$TAPIA_USER@$TAPIA_IP" "systemctl is-active --quiet autosmart"; then
41
    echo "✅ autosmart service is running on tapia"
42
else
43
    echo "❌ autosmart service failed to start!"
44
    exit 1
45
fi
46
echo ""
47

            
48
# 5. Check recent logs
49
echo "📋 Last 5 log entries from tapia:"
50
ssh "$TAPIA_USER@$TAPIA_IP" "tail -5 /var/log/syslog | grep autosmart" || true
51
echo ""
52

            
53
echo "✅ Deploy to tapia complete!"
54
echo ""
55
echo "Next: Verify data collection:"
56
echo "  ssh root@ebony \"psql -h 192.168.2.102 -U postgres -d autosmart\""
57
echo "  SELECT node_id, COUNT(*) FROM smart_collection_events GROUP BY node_id;"