Skip to content

Instantly share code, notes, and snippets.

@Madh93
Last active August 31, 2018 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Madh93/0801321f9fb9de2c5c2013751ecc5115 to your computer and use it in GitHub Desktop.
Save Madh93/0801321f9fb9de2c5c2013751ecc5115 to your computer and use it in GitHub Desktop.
Raspberry Pi Setup

Boards Setup

  • Orange Pi Zero
  • Raspberry Pi 3 Model B
#! /bin/bash
# --- TESTED ON ---
# Board: Orange Pi Zero
# OS: Armbian 5.59 Debian Stretch
# Kernel: 4.14.65
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1
exit 1
fi
MY_USER="migue"
MY_HOSTNAME="orange"
MY_LAN_IP="192.168.1.38/24"
MY_GATEWAY="192.168.1.1"
MY_DNS_SERVERS="8.8.8.8,8.8.4.4"
# Change hostname
hostnamectl set-hostname $MY_HOSTNAME
sed -i "s/orangepizero/$MY_HOSTNAME/g" /etc/hosts
# Network configuration
nmcli radio wifi off
nmcli connection modify "Wired connection 1" ipv4.method "manual" ipv4.address "$MY_LAN_IP" ipv.gateway "$MY_GATEWAY" ipv4.dns "$MY_DNS_SERVERS"
# Set locale to es_ES.UTF-8
localectl set-locale LANG="es_ES.utf-8"
LANG=es_ES.utf-8
# Set Time Zone
timedatectl set-timezone 'UTC'
systemctl restart rsyslog
# Update system
apt update && apt upgrade -y && apt-get autoremove -y
echo "\n\nYou must reboot the system now!"
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1
exit 1
fi
MY_USER="migue"
MY_HOSTNAME="raspi"
MY_GATEWAY_IP="192.168.1.1"
MY_LAN_IP="192.168.1.34"
MY_WIFI_IP="192.168.1.35"
MY_DNS_IP="8.8.8.8 8.8.4.4"
# Create user
adduser $MY_USER
usermod -aG sudo,pi,adm,dialout,cdrom,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio $MY_USER
# Enable autologin
sed -i "s/--autologin pi/--autologin $MY_USER/g" /etc/systemd/system/autologin@.service
# Change hostname
echo $MY_HOSTNAME > /etc/hostname
sed -i "s/raspberry/$MY_HOSTNAME/g" /etc/hosts
# Disable wifi and bluetooth
echo "dtoverlay=pi3-disable-wifi" >> /boot/config.txt
echo "dtoverlay=pi3-disable-bt" >> /boot/config.txt
# Enable ssh
systemctl start ssh
systemctl enable ssh
# Edit network configuration
echo "interface eth0" >> /etc/dhcpcd.conf
echo "static ip_address=$MY_LAN_IP/24" >> /etc/dhcpcd.conf
echo "static routers=$MY_GATEWAY_IP" >> /etc/dhcpcd.conf
echo "static domain_name_servers=$MY_DNS_IP" >> /etc/dhcpcd.conf
echo "interface wlan0" >> /etc/dhcpcd.conf
echo "static ip_address=$MY_WIFI_IP/24" >> /etc/dhcpcd.conf
echo "static routers=$MY_GATEWAY_IP" >> /etc/dhcpcd.conf
echo "static domain_name_servers=$MY_DNS_IP" >> /etc/dhcpcd.conf
# Set Time Zone
timedatectl set-timezone 'Atlantic/Canary'
systemctl restart rsyslog
# Set the keyboard to ES
cp /etc/default/keyboard /etc/default/keyboard.old
sed -i -e "/XKBLAYOUT=/s/gb/es/" /etc/default/keyboard
service keyboard-setup restart
# Set locale to es_ES.UTF-8
cp /etc/locale.gen /etc/locale.gen.old
sed -i -e "/^[^#]/s/^/#/" -e "/es_ES.UTF-8/s/^#//" /etc/locale.gen
cp /var/cache/debconf/config.dat /var/cache/debconf/config.dat.old
sed -i -e "/^Value: en_GB.UTF-8/s/en_GB/es_ES/" \
-e "/^ locales = en_GB.UTF-8/s/en_GB/es_ES/" /var/cache/debconf/config.dat
locale-gen
update-locale LANG=es_ES.UTF-8
echo "\n\nYou must reboot the system now!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment