update
This commit is contained in:
@@ -6,13 +6,15 @@ Based on the Rpi4 or CM4.
|
|||||||
|
|
||||||
# Express
|
# Express
|
||||||
|
|
||||||
You can download the `installation.sh` and run it:
|
You can download the `installation_part1.sh` and run it:
|
||||||
```
|
```
|
||||||
wget http://gitea.aircarto.fr/PaulVua/nebuleair_pro_4g/raw/branch/main/installation.sh
|
wget http://gitea.aircarto.fr/PaulVua/nebuleair_pro_4g/raw/branch/main/installation_part1.sh
|
||||||
chmod +x installation.sh
|
chmod +x installation.sh
|
||||||
sudo ./installation.sh
|
sudo ./installation.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
After reboot you can do the same with part 2.
|
||||||
|
|
||||||
|
|
||||||
## General
|
## General
|
||||||
|
|
||||||
|
|||||||
44
installation.sh → installation_part1.sh
Executable file → Normal file
44
installation.sh → installation_part1.sh
Executable file → Normal file
@@ -133,50 +133,6 @@ success "I2C ports enabled."
|
|||||||
info "Creates sqlites databases..."
|
info "Creates sqlites databases..."
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py
|
||||||
|
|
||||||
#set up SARA R4 APN
|
|
||||||
info "Set up Monogoto APN"
|
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setAPN.py ttyAMA2 data.mono 2
|
|
||||||
|
|
||||||
#Connect to network
|
|
||||||
info "Connect SARA R4 to network"
|
|
||||||
python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ttyAMA2 20810 60
|
|
||||||
|
|
||||||
#Add master_nebuleair.service
|
|
||||||
SERVICE_FILE="/etc/systemd/system/master_nebuleair.service"
|
|
||||||
info "Setting up systemd service for master_nebuleair..."
|
|
||||||
|
|
||||||
# Create the systemd service file (overwrite if necessary)
|
|
||||||
sudo bash -c "cat > $SERVICE_FILE" <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Master manager for the Python loop scripts
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/master.py
|
|
||||||
Restart=always
|
|
||||||
User=root
|
|
||||||
WorkingDirectory=/var/www/nebuleair_pro_4g
|
|
||||||
StandardOutput=append:/var/www/nebuleair_pro_4g/logs/master.log
|
|
||||||
StandardError=append:/var/www/nebuleair_pro_4g/logs/master_errors.log
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
success "Systemd service file created: $SERVICE_FILE"
|
|
||||||
|
|
||||||
# Reload systemd to recognize the new service
|
|
||||||
info "Reloading systemd daemon..."
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
|
|
||||||
# Enable the service to start on boot
|
|
||||||
info "Enabling the service to start on boot..."
|
|
||||||
sudo systemctl enable master_nebuleair.service
|
|
||||||
|
|
||||||
# Start the service immediately
|
|
||||||
info "Starting the service..."
|
|
||||||
sudo systemctl start master_nebuleair.service
|
|
||||||
|
|
||||||
|
|
||||||
# Completion message
|
# Completion message
|
||||||
success "Setup completed successfully!"
|
success "Setup completed successfully!"
|
||||||
67
installation_part2.sh
Normal file
67
installation_part2.sh
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on error, unset variable usage, and error in a pipeline
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Define color variables
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
NC='\033[0m' # No color
|
||||||
|
|
||||||
|
# Function to print messages in color
|
||||||
|
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||||
|
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||||
|
warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||||
|
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
|
||||||
|
|
||||||
|
# Check for root privileges
|
||||||
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
|
error "This script must be run as root. Use 'sudo ./installation.sh'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#set up SARA R4 APN
|
||||||
|
info "Set up Monogoto APN"
|
||||||
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setAPN.py ttyAMA2 data.mono 2
|
||||||
|
|
||||||
|
#Connect to network
|
||||||
|
info "Connect SARA R4 to network"
|
||||||
|
python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ttyAMA2 20810 60
|
||||||
|
|
||||||
|
#Add master_nebuleair.service
|
||||||
|
SERVICE_FILE="/etc/systemd/system/master_nebuleair.service"
|
||||||
|
info "Setting up systemd service for master_nebuleair..."
|
||||||
|
|
||||||
|
# Create the systemd service file (overwrite if necessary)
|
||||||
|
sudo bash -c "cat > $SERVICE_FILE" <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Master manager for the Python loop scripts
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/master.py
|
||||||
|
Restart=always
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/var/www/nebuleair_pro_4g
|
||||||
|
StandardOutput=append:/var/www/nebuleair_pro_4g/logs/master.log
|
||||||
|
StandardError=append:/var/www/nebuleair_pro_4g/logs/master_errors.log
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
success "Systemd service file created: $SERVICE_FILE"
|
||||||
|
|
||||||
|
# Reload systemd to recognize the new service
|
||||||
|
info "Reloading systemd daemon..."
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
# Enable the service to start on boot
|
||||||
|
info "Enabling the service to start on boot..."
|
||||||
|
sudo systemctl enable master_nebuleair.service
|
||||||
|
|
||||||
|
# Start the service immediately
|
||||||
|
info "Starting the service..."
|
||||||
|
sudo systemctl start master_nebuleair.service
|
||||||
Reference in New Issue
Block a user