5.4 KiB
5.4 KiB
Raspberry Pi/Debian Automated Setup Scripts
Overview
This project provides a collection of scripts to automate the configuration of Raspberry Pi or Debian-based systems. The main script (setup_raspberry.sh) allows you to easily configure network settings, disable the graphical interface to save RAM, and customize system behavior.
Features
- Set static MAC address for Ethernet interface (eth0)
- Automatically disable Wi-Fi (wlan0) if Ethernet is active and has an IP
- Configure static IP address with custom gateway
- Disable graphical environment to save system resources
- Custom welcome message with system information
- Automated setup with a single command
Prerequisites
- Raspberry Pi or Debian-based Linux system
- Internet connection
- sudo privileges
Installation & Usage
Quick Setup via curl
You can execute the setup script directly from GitLab using curl:
Basic interactive setup (prompts for each option):
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash
Configure MAC address only:
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "94:29:48:23:6A:B8"
Configure MAC address and disable GUI:
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "94:29:48:23:6A:B8" disable_gui
Configure MAC, disable GUI, and set static IP with gateway:
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "94:29:48:23:6A:B8" disable_gui "192.168.1.100/24" "192.168.1.1"
Manual Installation
Alternatively, download and run the script locally:
- Download the setup script:
wget https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh
- Make it executable:
chmod +x setup_raspberry.sh
- Run the script:
sudo ./setup_raspberry.sh
Script Parameters
The setup_raspberry.sh script accepts these parameters in order:
- MAC_ADDRESS (e.g., "94:29:48:23:6A:B8")
- GUI_ACTION (use "disable_gui" to disable graphical environment)
- IP_ADDRESS (e.g., "192.168.1.100/24")
- GATEWAY (e.g., "192.168.1.1")
Components
1. set_mac_wifi.sh
- Sets static MAC address for eth0
- Disables wlan0 if eth0 gets an IP address after 60 seconds
- Logs all actions to /var/log/set_mac.log
2. gui_manager.sh
- Manages graphical environment (enable/disable)
- Helps save RAM by disabling GUI when not needed
- Usage:
- Disable GUI:
sudo GUI_ACTION=disable /usr/local/bin/gui_manager.sh - Enable GUI:
sudo GUI_ACTION=enable /usr/local/bin/gui_manager.sh
- Disable GUI:
3. set_static_ip.sh
- Configures static IP for active interface (eth0 or wlan0)
- Supports custom gateway configuration
- Automatically detects network management system (dhcpcd, netplan, NetworkManager)
- Usage:
- With parameters:
sudo IP_ADDRESS=192.168.1.100/24 GATEWAY=192.168.1.1 /usr/local/bin/set_static_ip.sh - Interactive:
sudo /usr/local/bin/set_static_ip.sh
- With parameters:
4. welcome.sh
- Displays custom welcome message on login
- Shows system information (uptime, IP, memory usage, etc.)
- Automatically added to /etc/profile
Configuration Examples
Example 1: Minimal Configuration (MAC only)
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "00:1A:2B:3C:4D:5E"
Example 2: Network Configuration
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "" "" "192.168.1.100/24" "192.168.1.1"
Example 3: Full Configuration
curl -s https://gitea.spiralragetech.com/tiago.aica/scripts/raw/branch/main/debian/setup_raspberry.sh | sudo bash -s "00:1A:2B:3C:4D:5E" disable_gui "192.168.1.100/24" "192.168.1.1"
Post-Installation
Checking Configurations
- View MAC configuration:
cat /usr/local/bin/set_mac_wifi.sh | grep ETH0_MAC | head -n 1 - View static IP configuration:
ip addr show - View crontab entries:
crontab -l
Manual Configuration
After installation, you can manually run any component:
# Change MAC address
sudo /usr/local/bin/set_mac_wifi.sh
# Change static IP
sudo IP_ADDRESS=192.168.1.200/24 GATEWAY=192.168.1.1 /usr/local/bin/set_static_ip.sh
# Toggle GUI
sudo GUI_ACTION=enable /usr/local/bin/gui_manager.sh
Troubleshooting
-
Check log files for errors:
cat /var/log/raspberry_setup.log cat /var/log/set_mac.log cat /var/log/set_static_ip.log cat /var/log/gui_manager.log -
Verify network configuration:
ip addr show ip route show cat /etc/resolv.conf -
Check service status:
systemctl status dhcpcd systemctl status networking
Notes
- The scripts will create backups of configuration files before making changes.
- A reboot is recommended after configuration to ensure all changes take effect.
- For security, the scripts set proper permissions on configuration files.
- The setup script will prompt before making any changes to your system.
Support
For issues or questions:
- Check the log files in /var/log/
- Verify your network configuration
- Ensure you have sudo privileges
- Check the project repository for updates