update
This commit is contained in:
@@ -99,13 +99,48 @@ fi
|
||||
|
||||
# Add sudo authorization (prevent duplicate entries)
|
||||
info "Setting up sudo authorization..."
|
||||
if ! sudo grep -q "/usr/bin/nmcli" /etc/sudoers; then
|
||||
echo -e "ALL ALL=(ALL) NOPASSWD: /usr/bin/nmcli, /usr/sbin/reboot\nwww-data ALL=(ALL) NOPASSWD: /usr/bin/git pull\nwww-data ALL=(ALL) NOPASSWD: /usr/bin/ssh\nwww-data ALL=(ALL) NOPASSWD: /usr/bin/python3 * www-data ALL=(ALL) NOPASSWD: /bin/systemctl * www-data ALL=(ALL) NOPASSWD: /var/www/nebuleair_pro_4g/*" | sudo tee -a /etc/sudoers > /dev/null
|
||||
SUDOERS_FILE="/etc/sudoers"
|
||||
|
||||
# First, fix any existing syntax errors
|
||||
if sudo visudo -c 2>&1 | grep -q "syntax error"; then
|
||||
warning "Syntax error detected in sudoers file. Attempting to fix..."
|
||||
# Remove the problematic line if it exists
|
||||
sudo sed -i '/www-data ALL=(ALL) NOPASSWD: \/usr\/bin\/python3 \* www-data/d' "$SUDOERS_FILE"
|
||||
fi
|
||||
|
||||
# Add proper sudo rules (each on a separate line)
|
||||
if ! sudo grep -q "/usr/bin/nmcli" "$SUDOERS_FILE"; then
|
||||
# Create a temporary file with the new rules
|
||||
cat <<EOF | sudo tee /tmp/sudoers_additions > /dev/null
|
||||
# NebuleAir Pro 4G sudo rules
|
||||
ALL ALL=(ALL) NOPASSWD: /usr/bin/nmcli, /usr/sbin/reboot
|
||||
www-data ALL=(ALL) NOPASSWD: /usr/bin/git pull
|
||||
www-data ALL=(ALL) NOPASSWD: /usr/bin/ssh
|
||||
www-data ALL=(ALL) NOPASSWD: /usr/bin/python3 *
|
||||
www-data ALL=(ALL) NOPASSWD: /bin/systemctl *
|
||||
www-data ALL=(ALL) NOPASSWD: /var/www/nebuleair_pro_4g/*
|
||||
EOF
|
||||
|
||||
# Validate the temporary file
|
||||
if sudo visudo -c -f /tmp/sudoers_additions; then
|
||||
# Append to sudoers if valid
|
||||
sudo cat /tmp/sudoers_additions >> "$SUDOERS_FILE"
|
||||
success "Sudo authorization added."
|
||||
else
|
||||
error "Failed to add sudo rules - syntax validation failed."
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
sudo rm -f /tmp/sudoers_additions
|
||||
else
|
||||
warning "Sudo authorization already set. Skipping."
|
||||
fi
|
||||
|
||||
# Validate sudoers file after changes
|
||||
if ! sudo visudo -c; then
|
||||
error "Sudoers file has syntax errors! Please fix manually with 'sudo visudo'"
|
||||
fi
|
||||
|
||||
# Open all UART serial ports (avoid duplication)
|
||||
info "Configuring UART serial ports..."
|
||||
if ! grep -q "enable_uart=1" /boot/firmware/config.txt; then
|
||||
@@ -128,6 +163,13 @@ success "I2C ports enabled."
|
||||
info "Creates sqlites databases..."
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py
|
||||
|
||||
# Final sudoers check
|
||||
if sudo visudo -c; then
|
||||
success "Sudoers file is valid."
|
||||
else
|
||||
error "Sudoers file has errors! System may not function correctly."
|
||||
fi
|
||||
|
||||
# Completion message
|
||||
success "Setup completed successfully!"
|
||||
info "System will reboot in 5 seconds..."
|
||||
|
||||
@@ -35,7 +35,7 @@ CSV PAYLOAD (AirCarto Servers)
|
||||
3 -> temp
|
||||
4 -> hum
|
||||
5 -> press
|
||||
6 -> avg_noise
|
||||
6 -> avg_noise (DB_A)
|
||||
7 -> max_noise
|
||||
8 -> min_noise
|
||||
9 -> envea_no2
|
||||
@@ -216,7 +216,8 @@ npm_5channel = config.get('npm_5channel', False) #5 canaux du NPM
|
||||
envea_cairsens= config.get('envea', False)
|
||||
wind_meter= config.get('windMeter', False)
|
||||
bme_280_config = config.get('BME280', False)
|
||||
mppt_charger= config.get('MPPT', False)
|
||||
mppt_charger = config.get('MPPT', False)
|
||||
NOISE_sensor = config.get('NOISE', False)
|
||||
|
||||
#update device id in the payload json
|
||||
payload_json["nebuleairid"] = device_id
|
||||
@@ -827,6 +828,19 @@ try:
|
||||
else:
|
||||
print("No data available in the database.")
|
||||
|
||||
# NOISE sensor
|
||||
if NOISE_sensor:
|
||||
print("➡️Getting NOISE sensor values")
|
||||
cursor.execute("SELECT * FROM data_NOISE ORDER BY rowid DESC LIMIT 1")
|
||||
last_row = cursor.fetchone()
|
||||
if last_row:
|
||||
print("SQLite DB last available row:", last_row)
|
||||
cur_LEQ = last_row[1]
|
||||
DB_A_value = last_row[2]
|
||||
|
||||
#Add data to payload CSV
|
||||
payload_csv[6] = DB_A_value
|
||||
|
||||
#print("Verify SARA connection (AT)")
|
||||
|
||||
# Getting the LTE Signal (AT+CSQ)
|
||||
|
||||
Reference in New Issue
Block a user