Skip to content

Setup a minimal raspbian installation with some useful features.

Notifications You must be signed in to change notification settings

NxRoot/rpi-auto-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

RPI - Auto Setup

Automated tool to setup a minimal raspbian installation with some useful features.

TFT Screen Script Execution Web Applications

Features

  • 💯  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.

 

First Steps

  Flash SD Card with Raspbian OS
  1.   Choose Device (RPI 3, 4, 400, 5)

  2.   Choose OS --> Raspberry Pi OS (Other)

  3.   Select Raspbian x64 Legacy - No Desktop (0.3gb)

  4.   Choose USB Storage (SD Card Drive)

  5.   Configure settings before flashing

    • Setup Wifi Network
    • Enable SSH
    • User: pi
    • Password: YOUR PASSWORD
  Connect to device using SSH
  1.   Open terminal on a pc in the same network

  2.   Find the IP address of your RPI

    nslookup raspberrypi
  3.   Connect to RPI using SSH

    ssh pi@xxx.xxx.xxx

 

Installation

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

Usage

rpia --autologin=B2 --server=node --client=js --splash=off --chrome --smb --reboot
  --hello

Test Script

rpia --hello
  --splash

Enable/Disable Splashscreen

This will change the config file located at: /boot/config.txt

# Enable
rpia --splash=on

# Disable
rpia --splash=off
  --autologin

Configure boot mode

# B1 - Console
rpia --autologin=B1

# B2 - Console Autologin
rpia --autologin=B2

# B3 - Desktop
rpia --autologin=B3

# B4 - Desktop Autologin
rpia --autologin=B4
  --reboot

Reboot after installation

rpia --reboot
  --destroy

Remove rpia after installation

rpia --destroy
  --server

Host REST API

This will host a local server running on http://localhost:5001

# Node JS
rpia --server=node

# Python
rpia --server=python
  --client

Host Web App

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
  --sherlock

Install Sherlock OSINT

Please read documentation: Sherlock

rpia --sherlock
  --chrome

Run Browser on Boot

You must enable Console Auto-Login on the Raspbian Config.

# Open localhost
rpia --chrome

# Open specific URL
rpia --chrome=https://youtube.com
  --msf

Install Metasploit Framework

Please read documentation: Metasploit

rpia --msf
  --smb

Host Shared Folder with Samba

Please read documentation: Samba

rpia --smb
  --tft

Setup TFT Screen

Please read documentation to find your TFT model: LCD-WIKI

rpia --tft=MHS35

 

Custom

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

Lets make a script to install nmap

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

 

Documentation

  Host REST API + UI

REST API

This will host a local server running on http://localhost:5001

  Using NodeJS

Install NodeJS

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Create Folder

mkdir ~/pi-server
cd ~/pi-server

Create 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)

Initialize Project

npm init

Install Express JS

npm i express

Start Server

npm start
  Using Python

Create Folder

mkdir ~/pi-server
cd ~/pi-server

Create virtual environment

python3 -m venv venv

Activate virtual environment

source venv/bin/activate

Install Flask

pip install flask
pip install python-dotenv

Create Server

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"

Start Server

venv/bin/flask --app ./server.py run --no-debugger



Web App

This will add a web application to the previously hosted server.

  Using Html

Create Folders

cd ~/pi-server
mkdir client
mkdir client/build

Create Website

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

Install NodeJS

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Create React App

cd ~/pi-server
npx create-react-app client

Build Website

cd ~/pi-server/client
npm run build



  Sharing Files with SMB

Create Folder

mkdir ~/shared
sudo chmod -R 777 ~/shared

Install Samba

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.

Install Chromium

sudo apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox chromium-browser

Boot Config

sudo nano ~/.bash_profile

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor

Start Script

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

Install GIT

sudo apt install -y git

Install TFT Drivers

git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./MHS35-show
sudo reboot



About

Setup a minimal raspbian installation with some useful features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages