An open API service indexing awesome lists of open source software.

https://github.com/nxroot/rpi-auto-setup

Setup a minimal raspbian installation with some useful features.
https://github.com/nxroot/rpi-auto-setup

bootscripts raspberry-pi react-app rpi3 rpi4 web-server

Last synced: 10 months ago
JSON representation

Setup a minimal raspbian installation with some useful features.

Awesome Lists containing this project

README

          

# 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. ###   Open [Raspberry Pi Imager](https://www.raspberrypi.com/software/)
2. ###   Choose Device (RPI 3, 4, 400, 5)
3. ###   Choose OS --> `Raspberry Pi OS (Other)`
4. ###   Select `Raspbian x64 Legacy - No Desktop (0.3gb)`
5. ###   Choose USB Storage (SD Card Drive)
6. ###   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
```bash
nslookup raspberrypi
```
3. ###   Connect to RPI using SSH
```bash
ssh pi@xxx.xxx.xxx
```

 

## Installation

```tsx
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
```console
rpia --autologin=B2 --server=node --client=js --splash=off --chrome --smb --reboot
```

  --hello

#### Test Script
```bash
rpia --hello
```

  --splash

#### Enable/Disable Splashscreen
> This will change the config file located at: `/boot/config.txt`
```bash
# Enable
rpia --splash=on

# Disable
rpia --splash=off
```

  --autologin

#### Configure boot mode
```bash
# 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
```bash
rpia --reboot
```

  --destroy

#### Remove rpia after installation
```bash
rpia --destroy
```

  --server

#### Host REST API
> This will host a local server running on http://localhost:5001
```bash
# 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`.

```bash
# Javascript
rpia --client=js

# React
rpia --client=react
```

  --sherlock

#### Install Sherlock OSINT
> Please read documentation: [Sherlock](https://github.com/sherlock-project/sherlock)
```bash
rpia --sherlock
```

  --chrome

#### Run Browser on Boot
> You must enable Console Auto-Login on the Raspbian Config.
```bash
# Open localhost
rpia --chrome

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

  --msf

#### Install Metasploit Framework
> Please read documentation: [Metasploit](https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html)
```bash
rpia --msf
```

  --smb

#### Host Shared Folder with Samba
> Please read documentation: [Samba](https://www.jeffgeerling.com/blog/2021/htgwa-create-samba-smb-share-on-raspberry-pi)
```bash
rpia --smb
```

  --tft

#### Setup TFT Screen
> Please read documentation to find your TFT model: [LCD-WIKI](http://www.lcdwiki.com/Main_Page)
```bash
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.
```bash
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
```bash
#!/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
```bash
# 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
```bash
#!/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
```console
rpia --nmap
```

 

## Documentation

  Host REST API + UI




## REST API
> This will host a local server running on http://localhost:5001

  Using NodeJS

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

### Create Folder
```bash
mkdir ~/pi-server
cd ~/pi-server
```

### Create Server
`sudo nano server.js`
```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
```bash
npm init
```

### Install Express JS
```bash
npm i express
```

### Start Server
```bash
npm start
```



  Using Python

### Create Folder
```bash
mkdir ~/pi-server
cd ~/pi-server
```

### Create virtual environment
```bash
python3 -m venv venv
```

### Activate virtual environment
```bash
source venv/bin/activate
```

### Install Flask
```bash
pip install flask
pip install python-dotenv
```

### Create Server
`sudo nano server.py`
```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
```bash
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
```bash
cd ~/pi-server
mkdir client
mkdir client/build
```
### Create Website
`sudo nano client/build/index.html`
```html








Hello world!




```



  Using React

### Install NodeJS
```bash
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
```
### Create React App
```bash
cd ~/pi-server
npx create-react-app client
```
### Build Website
```bash
cd ~/pi-server/client
npm run build
```



  Sharing Files with SMB

### Create Folder
```bash
mkdir ~/shared
sudo chmod -R 777 ~/shared
```
### Install Samba
```bash
sudo apt install -y samba samba-common-bin
```
### Config Samba ([More](https://www.jeffgeerling.com/blog/2021/htgwa-create-samba-smb-share-on-raspberry-pi))
`sudo nano /etc/samba/smb.conf`
```bash
# 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
```bash
sudo apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox chromium-browser
```

### Boot Config
`sudo nano ~/.bash_profile`
```bash
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
```

### Start Script
`sudo nano ~/.xinitrc`
```bash
#!/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](http://www.lcdwiki.com/Main_Page)

### Install GIT
```bash
sudo apt install -y git
```

### Install TFT Drivers
```bash
git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./MHS35-show
sudo reboot
```