Automated tool to setup a minimal raspbian installation with some useful features.
TFT Screen | Script Execution | Web Applications |
---|---|---|
- 💯 Powerful scripting and configuration tool.
- 🧬 Install multiple tools with a single command.
- ✍️ Create your own scripts to install custom tools.
- ✅ Host pre-configured web servers and applications.
- 🚀 Extremely lightweight and ultra-flexible configuration.
Flash SD Card with Raspbian OS
-
Open Raspberry Pi Imager
-
- Setup Wifi Network
- Enable SSH
- User: pi
- Password: YOUR PASSWORD
Connect to device using SSH
-
nslookup raspberrypi
sudo apt install -y git
sudo rm -rf ~/rpia
git clone https://github.com/NxRoot/rpi-auto-setup.git ~/rpia
sudo cp ~/rpia/install /usr/local/bin/rpia
sudo chmod +x /usr/local/bin/rpia
rpia --autologin=B2 --server=node --client=js --splash=off --chrome --smb --reboot
--splash
This will change the config file located at:
/boot/config.txt
# Enable
rpia --splash=on
# Disable
rpia --splash=off
--autologin
# B1 - Console
rpia --autologin=B1
# B2 - Console Autologin
rpia --autologin=B2
# B3 - Desktop
rpia --autologin=B3
# B4 - Desktop Autologin
rpia --autologin=B4
--server
This will host a local server running on http://localhost:5001
# Node JS
rpia --server=node
# Python
rpia --server=python
--client
This will add a web application to a server hosted by the
--server
argument.
This can only be used after--server
.
# Javascript
rpia --client=js
# React
rpia --client=react
--chrome
You must enable Console Auto-Login on the Raspbian Config.
# Open localhost
rpia --chrome
# Open specific URL
rpia --chrome=https://youtube.com
You can create your own modules using bash script.
The modules
folder contains an example script that you can use as reference.
cat ~/rpia/modules/hello/install
The first 3 arguments will be received in every script.
$root
Path to home folder$rpias
Path to rpia folder$value
Passed in command --key=value
#!/bin/bash
root=$1
rpias=$2
value=$3
dir=$(dirname $0)
echo This is a test script
echo $root $rpias $value $dir
First steps
# Go to 'modules' folder
cd ~/rpia/modules
# Copy example script to 'nmap' folder
cp hello nmap
# Open the script with text editor
nano nmap/install
The script content
#!/bin/bash
root=$1
rpias=$2
value=$3
dir=$(dirname $0)
# install nmap
sudo apt install -y nmap
# print some message
echo "Successfully installed 'Nmap'"
Calling your script
rpia --nmap
Host REST API + UI
This will host a local server running on http://localhost:5001
Using NodeJS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
mkdir ~/pi-server
cd ~/pi-server
sudo nano server.js
const path = require('path')
const express = require('express')
const app = express()
const PORT = 5001
// serve static assets
app.use(express.static('client/build'));
// Create API endpoints
app.get('/api/message', (req, res) => {
res.json({message: "Hello from Express JS"})
});
// Send everything else to static content
app.get('*', (req, res) => res.sendFile(path.resolve(__dirname, 'client/build', 'index.html')));
// Open server on specified port
console.log('Server started on port:', PORT)
app.listen(PORT)
npm init
npm i express
npm start
Using Python
mkdir ~/pi-server
cd ~/pi-server
python3 -m venv venv
source venv/bin/activate
pip install flask
pip install python-dotenv
sudo nano server.py
from flask import Flask
app = Flask(__name__, static_folder='./client/build', static_url_path='/')
@app.route('/', methods=['GET'])
def index():
return app.send_static_file('index.html')
@app.route('/api/message', methods=['GET'])
def message():
return "Hello from Python"
venv/bin/flask --app ./server.py run --no-debugger
This will add a web application to the previously hosted server.
Using Html
cd ~/pi-server
mkdir client
mkdir client/build
sudo nano client/build/index.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>
Hello world!
</h1>
</body>
</html>
Using React
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
cd ~/pi-server
npx create-react-app client
cd ~/pi-server/client
npm run build
Sharing Files with SMB
mkdir ~/shared
sudo chmod -R 777 ~/shared
sudo apt install -y samba samba-common-bin
Config Samba (More)
sudo nano /etc/samba/smb.conf
# Add to end of file
[shared]
path=/home/pi/shared
public = yes
read only = no
guest only = yes
writeable = yes
browseable = yes
guest ok = yes
force create mode = 0666
force directory mode = 0777
Open browser on boot
You must enable Console Auto-Login on the Raspbian Config.
sudo apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox chromium-browser
sudo nano ~/.bash_profile
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
sudo nano ~/.xinitrc
#!/usr/bin/env sh
GEO="$(fbset -s | awk '$1 == "geometry" { print $2":"$3 }')"
WIDTH=$(echo "$GEO" | cut -d: -f1)
HEIGHT=$(echo "$GEO" | cut -d: -f2)
# Hide console
xset -dpms
xset s off
xset s noblank
# Start browser
chromium-browser --kiosk "http://localhost:5001" \
--window-size=$WIDTH,$HEIGHT \
--window-position=-10,0 \
--start-fullscreen \
--start-maximized \
--kiosk \
--incognito \
--noerrdialogs \
--disable-translate \
--no-first-run \
--fast \
--fast-start \
--use-gl=none \
--autoplay-policy=no-user-gesture-required \
--disable-infobars \
--disable-features=TranslateUI \
--disk-cache-dir=/dev/null \
--overscroll-history-navigation=0 \
--disable-pinch \
--enable-kiosk-mode \
--enabled \
--disable-java \
--disable-restore-session-state \
--disable-sync --disable-translate \
--disable-touch-drag-drop \
--disable-touch-editing \
--test-type \
--ignore-certificate-errors \
--no-sandbox
Setup TFT Screen
Please read documentation for your TFT model: LCD-WIKI
sudo apt install -y git
git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./MHS35-show
sudo reboot