This is a collection of scripts I use to set up a Raspberry Pi. I primarily use them to run Ruby on Rails applications, so the current collection of scripts is focused on that. However, I have tried to avoid boxing myself into that, and would like to keep the install scripts as generic as possible.
This section covers the basics of getting your Pi up and running. It's mostly in place for my own documentation.
If you already have a working Pi and just want to use the Setup Scripts, jump to the Installation section below.
Visit the Raspbian Download Page and download the latest version. I recommend Stretch Lite and using the torrent to download it.
After the download has completed extract the archive
These instructions are for macOS. Installation instructions are available on the Raspberry Pi website for other platforms.
- Insert your SD Card into your Macbook
- Open Terminal
- Run
diskutil list
and identify the disk for your SD card. Mine is/dev/disk5
today. Sub the5
for your disk number. diskutil unmountDisk /dev/disk5
cd ~/Downloads
(or the directory where your.img
file is located)sudo dd bs=1m if=2016-09-23-raspbian-jessie-lite.img of=/dev/rdisk5
- Enter your password when prompted (due to the
sudo
) - Wait - It took 1 minute and 19 seconds for me.
- Add an empty file named 'ssh' to the boot partition:
touch /Volumes/boot/ssh
diskutil eject /dev/disk5
- Remove your SD Card from you laptop and insert in your Raspberry Pi
- Connect the Pi to your network, and apply power so it boots.
- Determine the IP address of the Pi (I'll leave the deatils of this to you)
- SSH into your Pi with
ssh pi@192.168.12.206
(default password israspberry
) sudo apt-get update && sudo apt-get upgrade -y
sudo raspi-config
Perform these actions in raspi-config:
- Change User Password
- Network Options
- Hostname
- Localisation Options
- Change Locale
- Select
en_US.UTF-8 UTF-8
and Deselecten_GB.UTF-8 UTF-8
(space toggles) - Set the default to
en_US.UTF-8
when prompted
- Select
- Change Timezone
- Change Locale
- Advanced Options
- Expand Filesystem
- Finish
- select
Yes
to reboot the Pi when prompted
- select
If you already have a public key and are familiar with how passwordless ssh access works, then this is easy. If you don't, you might want to just skip this. I'm not going to explain how to set up a public key.
On your local computer (NOT THE PI!) run: ssh-copy-id pi@192.168.12.206
You should now be able to SSH into the Pi without a password: ssh pi@192.168.12.206
You must have git
installed on your pi. You can install it with
sudo apt-get install git -y
Clone this repository into your home directory
git clone https://github.com/mcfadden/PiSetup.git ~/PiSetup
Run the setup script and select which items you wish to install
sudo ~/PiSetup/setup.sh
At this time, these items are available:
ruby.sh
This ruby install script installs ruby-build
and ruby
. It will install ruby to /usr/local
and become your system ruby.
It detects available versions provided by ruby-build
and defaults to the latests stable build. You will be prompted to select a version.
It disables RDoc for the ruby install, and globally disables docs for gem installation as well.
psql.sh
This PostgreSQL install script installs postgres-9.4
and performs a few configuration changes.
It changes the authentication method from peer
to md5
which simplifies connecting via a rails app.
It creates a user rails
with password rails
. Since we won't allow access to the database except via localhost
this is safe enough.
It also creates a user root
with no password. You can set up a password for this user if you desire.
nginx.sh
Installs and starts NGINX. You will need to configure it for your needs.
wiringPi.sh
WiringPi is a GPIO access library for the Raspberry Pi. It includes a command line utility gpio
.
See http://wiringpi.com for usage instructions.
- Redis