-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecute_oceanix.sh
More file actions
60 lines (53 loc) · 1.63 KB
/
execute_oceanix.sh
File metadata and controls
60 lines (53 loc) · 1.63 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
#!/bin/bash
# Define the repository URL and the local directory name
REPO_URL="https://github.com/PoliTOcean/Oceanix.git"
LOCAL_DIR="Oceanix"
EXECUTABLE="Oceanix"
# Check if the repository is already cloned
if [ ! -d "$LOCAL_DIR" ]; then
echo "Cloning the repository..."
git clone "$REPO_URL"
else
echo "Repository already cloned."
fi
# Navigate to the repository directory
cd "$LOCAL_DIR" || { echo "Failed to change directory to $LOCAL_DIR"; exit 1; }
if [ -f "build/$EXECUTABLE" ]; then
cd ..
else
# Check if install.sh exists
if [ -f "install.sh" ]; then
chmod +x ./install.sh
./install.sh
echo "Oceanix compiled"
cd ..
else
echo "install.sh not found or not executable."
exit 1
fi
fi
# Check the status of the Mosquitto service
service_status=$(sudo service mosquitto status)
# Check if the service is running
if echo "$service_status" | grep -q "mosquitto is running"; then
echo "Mosquitto is already running."
else
echo "Mosquitto is not running. Starting the service..."
sudo service mosquitto start
# Verify if the service started successfully
if sudo service mosquitto status | grep -q "mosquitto is running"; then
echo "Mosquitto has been started successfully."
else
echo "Failed to start Mosquitto."
fi
fi
# Check if the executable exists in the build directory
if [ -f "$LOCAL_DIR/build/$EXECUTABLE" ]; then
echo "Found $EXECUTABLE"
# Rename the executable
echo "Executing $EXECUTABLE in test mode"
$LOCAL_DIR/build/$EXECUTABLE test
else
echo "$EXECUTABLE not found in $LOCAL_DIR/build"
exit 1
fi