-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_vm_monitor.sh
More file actions
138 lines (115 loc) Β· 3.5 KB
/
setup_vm_monitor.sh
File metadata and controls
138 lines (115 loc) Β· 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# VM Monitor Setup Script
# This script clones the vm-monitor repository and sets up all components
set -e # Exit on any error
echo "π Starting VM Monitor setup..."
# Update system packages
echo "π¦ Updating system packages..."
sudo apt update && sudo apt upgrade -y
# Install essential build tools and dependencies
echo "π§ Installing build essentials and dependencies..."
sudo apt install -y \
build-essential \
curl \
wget \
git \
pkg-config \
libssl-dev \
libssl3 \
openssl \
ca-certificates \
gnupg \
lsb-release \
python3 \
python3-pip \
python3-venv \
python3-dev
# Clone the repository
echo "π Cloning vm-monitor repository..."
if [ -d "vm-monitor" ]; then
echo "β οΈ vm-monitor directory already exists. Removing it..."
rm -rf vm-monitor
fi
git clone https://github.com/frhanjav/vm-monitor.git
cd vm-monitor
# Install Node.js 20
echo "π’ Installing Node.js 20..."
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify Node.js installation
echo "β
Node.js version: $(node --version)"
echo "β
npm version: $(npm --version)"
# Install Rust and Cargo
echo "π¦ Installing Rust and Cargo..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/env
# Add cargo to PATH for current session
export PATH="$HOME/.cargo/bin:$PATH"
# Verify Rust installation
echo "β
Rust version: $(rustc --version)"
echo "β
Cargo version: $(cargo --version)"
# Setup vm-monitor-frontend
echo "π Setting up vm-monitor-frontend..."
cd vm-monitor-frontend
npm install
echo "β
Frontend dependencies installed successfully"
cd ..
# Setup vm-monitor (Rust project)
echo "π¦ Setting up vm-monitor Rust project..."
cd vm-monitor
# Set environment variables for OpenSSL
export OPENSSL_DIR=/usr
export OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu
export OPENSSL_INCLUDE_DIR=/usr/include/openssl
# Build the Rust project
echo "π¨ Building Rust project..."
cargo build
if [ $? -eq 0 ]; then
echo "β
Rust project built successfully"
else
echo "β Rust build failed"
exit 1
fi
cd ..
# Setup vm_monitor_api (Python project)
echo "π Setting up vm_monitor_api..."
cd vm_monitor_api
# Create virtual environment
echo "π§ Creating Python virtual environment..."
python3 -m venv venv
# Activate virtual environment
echo "π§ Activating virtual environment..."
source venv/bin/activate
# Install Python dependencies
echo "π¦ Installing Python dependencies..."
pip install -r requirements.txt
if [ $? -eq 0 ]; then
echo "β
Python dependencies installed successfully"
else
echo "β Python dependencies installation failed"
deactivate
exit 1
fi
# Deactivate virtual environment
deactivate
echo "β
Python virtual environment setup complete"
cd ..
# Final setup completion
echo ""
echo "π VM Monitor setup completed successfully!"
echo ""
echo "π Summary:"
echo " β
Repository cloned"
echo " β
Node.js 20 installed"
echo " β
Rust/Cargo installed"
echo " β
Python 3 with venv ready"
echo " β
Frontend dependencies installed"
echo " β
Rust project built"
echo " β
Python API dependencies installed"
echo ""
echo "π Next steps:"
echo " β’ Frontend: cd vm-monitor/vm-monitor-frontend && npm start"
echo " β’ Rust: cd vm-monitor/vm-monitor && cargo run"
echo " β’ Python API: cd vm-monitor/vm_monitor_api && source venv/bin/activate && python3 app.py"
echo ""
echo "π‘ Note: To use cargo in new terminals, run: source ~/.cargo/env"