Files
scripts/debian/README.md
T
2026-02-11 22:03:06 +00:00

170 lines
5.4 KiB
Markdown

# 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):
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/main/debian/setup_raspberry.sh | sudo bash
```
#### Configure MAC address only:
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/main/debian/setup_raspberry.sh | sudo bash -s "94:29:48:23:6A:B8"
```
#### Configure MAC address and disable GUI:
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/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:
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/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:
1. Download the setup script:
```bash
wget https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/main/debian/setup_raspberry.sh
```
2. Make it executable:
```bash
chmod +x setup_raspberry.sh
```
3. Run the script:
```bash
sudo ./setup_raspberry.sh
```
## Script Parameters
The setup_raspberry.sh script accepts these parameters in order:
1. MAC_ADDRESS (e.g., "94:29:48:23:6A:B8")
2. GUI_ACTION (use "disable_gui" to disable graphical environment)
3. IP_ADDRESS (e.g., "192.168.1.100/24")
4. 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`
### 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`
### 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)
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/main/debian/setup_raspberry.sh | sudo bash -s "00:1A:2B:3C:4D:5E"
```
### Example 2: Network Configuration
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/main/debian/setup_raspberry.sh | sudo bash -s "" "" "192.168.1.100/24" "192.168.1.1"
```
### Example 3: Full Configuration
```bash
curl -s https://gitlab.spiralragetech.com/tiago.aica/scripts-linux/-/raw/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:
```bash
# 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
1. **Check log files** for errors:
```bash
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
```
2. **Verify network configuration**:
```bash
ip addr show
ip route show
cat /etc/resolv.conf
```
3. **Check service status**:
```bash
systemctl status dhcpcd
systemctl status networking
```
## Notes
1. The scripts will create backups of configuration files before making changes.
2. A reboot is recommended after configuration to ensure all changes take effect.
3. For security, the scripts set proper permissions on configuration files.
4. The setup script will prompt before making any changes to your system.
## Support
For issues or questions:
1. Check the log files in /var/log/
2. Verify your network configuration
3. Ensure you have sudo privileges
4. Check the project repository for updates