-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·141 lines (114 loc) · 3.31 KB
/
install.sh
File metadata and controls
executable file
·141 lines (114 loc) · 3.31 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
139
140
141
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
#SUDO = "sudo"
mkdir -p tmp
cd tmp
# Check for SUDO
if ! command_exists sudo; then
echo "SUDO is not installed. Running commands without SUDO."
#SUDO="sudo"
fi
# Check for Git
if ! command_exists git; then
echo "Git is not installed. Installing Git..."
sudo apt-get update
sudo apt-get install -y git
else
echo "Git is already installed."
fi
# Check for CMake
if ! command_exists cmake; then
echo "CMake is not installed. Installing CMake..."
sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config
sudo cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++
else
echo "CMake is already installed."
fi
# Check for GCC
if ! command_exists gcc; then
echo "GCC is not installed. Installing GCC..."
sudo apt-get update
sudo apt-get install -y gcc g++
else
echo "GCC is already installed."
fi
# Check for OpenSSL
if ! dpkg -s libssl-dev >/dev/null 2>&1; then
echo "OpenSSL is not installed. Installing OpenSSL..."
sudo apt-get update
sudo apt-get install -y libssl-dev
else
echo "OpenSSL is already installed."
fi
# Check for libuv
if ! dpkg -s libuv1-dev >/dev/null 2>&1; then
echo "libuv is not installed. Installing libuv..."
sudo apt-get update
sudo apt-get install -y libuv1-dev
else
echo "libuv is already installed."
fi
# Check for Eclipse Paho MQTT C and C++ libraries
if ! ls /usr/local/lib | grep -q "libpaho-mqtt3as\|libpaho-mqttpp3"; then
echo "Eclipse Paho MQTT libraries are not installed. Installing Eclipse Paho MQTT libraries..."
sudo git clone https://github.com/eclipse/paho.mqtt.cpp.git
sudo git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
# Create a build directory
sudo mkdir build
cd build
# Configure and build
sudo cmake .. -DPAHO_WITH_SSL=ON -DPAHO_BUILD_STATIC=ON -DPAHO_BUILD_DOCUMENTATION=OFF
sudo make -j$(nproc)
# Install the library
sudo make install
sudo ldconfig
cd ../../paho.mqtt.cpp
# Create a build directory
sudo mkdir build
cd build
# Configure and build
sudo cmake .. -DPAHO_BUILD_DOCUMENTATION=OFF -DPAHO_WITH_SSL=ON
sudo make -j$(nproc)
# Install the library
sudo make install
sudo ldconfig
cd ../../
echo "Verify MQTT install..."
sudo ls /usr/local/lib | grep paho
else
echo "Eclipse Paho MQTT libraries are already installed."
fi
# Check for mosquitto
if ! command_exists mosquitto; then
echo "mosquitto is not installed. Installing mosquitto..."
sudo apt-get update
sudo apt install mosquitto mosquitto-clients -y
sudo cp ../.devcontainer/mosquitto /etc/init.d
# Add mosquitto.conf
echo "Adding mosquitto.conf..."
cat <<EOF | sudo tee /etc/mosquitto/conf.d/oceanix.conf
listener 1883 0.0.0.0 # Allow all IPv4 connections
allow_anonymous true # Allow unauthenticated clients (for testing)
listener 9000 0.0.0.0
protocol websockets
connection_messages true
EOF
sudo service mosquitto start
else
echo "mosquitto is already installed."
fi
cd ..
# Create a build directory
mkdir -p build
# Run CMake
echo "Running CMake..."
cmake -S . -B build
# Run Make
echo "Running Make..."
cmake --build build
echo "Installation and build process completed."