From 96e10ed5c379a0931d913dbda7eb880f52066f73 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Jun 2025 12:26:04 +0200 Subject: [PATCH] update --- installation.sh | 62 +++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/installation.sh b/installation.sh index a146deb..ee2c84e 100644 --- a/installation.sh +++ b/installation.sh @@ -226,7 +226,31 @@ configure_apache() { enable_hardware() { print_step "Enabling hardware interfaces..." - # Check if config.txt exists + # Enable I2C using raspi-config + print_status "Enabling I2C interface..." + if sudo raspi-config nonint do_i2c 0; then + print_success "I2C enabled via raspi-config" + else + print_warning "Failed to enable I2C via raspi-config" + fi + + # Enable SPI using raspi-config + print_status "Enabling SPI interface..." + if sudo raspi-config nonint do_spi 0; then + print_success "SPI enabled via raspi-config" + else + print_warning "Failed to enable SPI via raspi-config" + fi + + # Enable Serial/UART using raspi-config + print_status "Enabling Serial interface..." + if sudo raspi-config nonint do_serial 0; then + print_success "Serial enabled via raspi-config" + else + print_warning "Failed to enable Serial via raspi-config" + fi + + # Check if config.txt exists for additional UART configurations local config_file="/boot/firmware/config.txt" if [ ! -f "$config_file" ]; then config_file="/boot/config.txt" @@ -239,23 +263,7 @@ enable_hardware() { print_status "Using config file: $config_file" - # Enable I2C - if ! grep -q "^dtparam=i2c_arm=on" "$config_file"; then - echo "dtparam=i2c_arm=on" | sudo tee -a "$config_file" - print_success "I2C enabled in config.txt" - else - print_warning "I2C already enabled" - fi - - # Enable UART - if ! grep -q "^enable_uart=1" "$config_file"; then - echo "enable_uart=1" | sudo tee -a "$config_file" - print_success "UART enabled in config.txt" - else - print_warning "UART already enabled" - fi - - # Add UART configurations for multiple ports + # Add additional UART configurations for multiple ports local uart_configs=( "dtoverlay=uart2" "dtoverlay=uart3" @@ -271,6 +279,8 @@ enable_hardware() { print_warning "$config already configured" fi done + + print_success "Hardware interfaces configuration completed" } # Set device permissions @@ -416,17 +426,25 @@ final_status() { echo -e "${GREEN}✓${NC} Boot scripts created" print_header "NEXT STEPS" - echo -e "${YELLOW}1.${NC} Reboot the system to activate hardware interfaces:" + echo -e "${YELLOW}1.${NC} ${RED}REBOOT REQUIRED${NC} - Hardware interfaces need reboot to activate:" echo -e " ${CYAN}sudo reboot${NC}" echo -e "" - echo -e "${YELLOW}2.${NC} After reboot, check service status:" + echo -e "${YELLOW}2.${NC} After reboot, verify I2C and UART devices:" + echo -e " ${CYAN}ls -la /dev/i2c-* /dev/ttyAMA*${NC}" + echo -e "" + echo -e "${YELLOW}3.${NC} Check service status:" echo -e " ${CYAN}systemctl list-timers | grep moduleair${NC}" echo -e "" - echo -e "${YELLOW}3.${NC} Access web interface at:" + echo -e "${YELLOW}4.${NC} Test RTC module (after reboot):" + echo -e " ${CYAN}python3 /var/www/moduleair_pro_4g/RTC/read.py${NC}" + echo -e "" + echo -e "${YELLOW}5.${NC} Access web interface at:" echo -e " ${CYAN}http://$(hostname -I | awk '{print $1}')${NC}" echo -e "" - echo -e "${YELLOW}4.${NC} Check logs if needed:" + echo -e "${YELLOW}6.${NC} Check logs if needed:" echo -e " ${CYAN}tail -f /var/www/moduleair_pro_4g/logs/*.log${NC}" + echo -e "" + print_warning "I2C and UART devices will NOT work until after reboot!" } # Main installation function