update
This commit is contained in:
@@ -10,7 +10,7 @@ You can download the `installation.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.sh
|
||||||
chmod +x installation.sh
|
chmod +x installation.sh
|
||||||
./installation.sh
|
sudo ./installation.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
|
|||||||
|
|
||||||
# Check for root privileges
|
# Check for root privileges
|
||||||
if [[ "$EUID" -ne 0 ]]; then
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
error "This script must be run as root. Use 'sudo ./script.sh'"
|
error "This script must be run as root. Use 'sudo ./installation.sh'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update and install necessary packages
|
# Update and install necessary packages
|
||||||
@@ -65,12 +65,13 @@ fi
|
|||||||
# Set up repository files and permissions
|
# Set up repository files and permissions
|
||||||
info "Setting up repository files and permissions..."
|
info "Setting up repository files and permissions..."
|
||||||
sudo mkdir -p "$REPO_DIR/logs"
|
sudo mkdir -p "$REPO_DIR/logs"
|
||||||
sudo touch "$REPO_DIR/logs/app.log" "$REPO_DIR/logs/loop.log" "$REPO_DIR/wifi_list.csv"
|
sudo touch "$REPO_DIR/logs/app.log" "$REPO_DIR/logs/master.log" "$REPO_DIR/logs/master_errors.log" "$REPO_DIR/wifi_list.csv"
|
||||||
sudo cp "$REPO_DIR/config.json.dist" "$REPO_DIR/config.json"
|
sudo cp "$REPO_DIR/config.json.dist" "$REPO_DIR/config.json"
|
||||||
sudo chmod -R 755 "$REPO_DIR/"
|
sudo chmod -R 755 "$REPO_DIR/"
|
||||||
sudo chown -R www-data:www-data "$REPO_DIR/"
|
sudo chown -R www-data:www-data "$REPO_DIR/"
|
||||||
sudo -u www-data git config --global core.fileMode false
|
sudo git config --global core.fileMode false
|
||||||
sudo -u www-data git config --global --add safe.directory "$REPO_DIR"
|
sudo git -C /var/www/nebuleair_pro_4g config core.fileMode false
|
||||||
|
sudo git config --global --add safe.directory "$REPO_DIR"
|
||||||
|
|
||||||
# Set up cron jobs (ensure file exists first)
|
# Set up cron jobs (ensure file exists first)
|
||||||
info "Setting up cron jobs..."
|
info "Setting up cron jobs..."
|
||||||
@@ -128,6 +129,43 @@ info "Enabling I2C ports..."
|
|||||||
sudo raspi-config nonint do_i2c 0
|
sudo raspi-config nonint do_i2c 0
|
||||||
success "I2C ports enabled."
|
success "I2C ports enabled."
|
||||||
|
|
||||||
|
#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!"
|
||||||
info "System will reboot in 5 seconds..."
|
info "System will reboot in 5 seconds..."
|
||||||
|
|||||||
Reference in New Issue
Block a user