Skip to content

Instantly share code, notes, and snippets.

@Descent098
Last active September 19, 2022 05: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 Descent098/3f87ec5c03a36daa0522a62fb6d175ef to your computer and use it in GitHub Desktop.
Save Descent098/3f87ec5c03a36daa0522a62fb6d175ef to your computer and use it in GitHub Desktop.
Guide to setting up raspberry pi's in 2022!

Setting up Pi's

To setup your Pi initially install using the imager, after selecting 64-bit os (lite or normal) go into the settings.

Make sure you:

  • set your hostname to what you want
  • allow SSH
  • set a password & username (I usually just leave the username as default)
  • setup a WLAN (if not using ethernet, and make sure to set your country)

Copy the script

I have written a script to set things up for you including installing micro an easy to use command line editor, docker & docker compose and a docker/ docker compose manager. Copy the script in this gist to the pi using scp (change hostname to IP/hostname, and pi to username you set if you changed it):

scp setup-pi-docker.sh pi@hostname:~

When you SSH into the pi using:

ssh pi@hostname

Then set everything up using:

chmod +x setup-pi-docker.sh && sudo setup-pi-docker.sh

Recommended apps

Heimdall; A easy dashboard for you to add your apps to

PiHole; DNS server that can be a DNS sinkhole for ads/malware

Setting up apps that don't work

Many apps don't work on ARM processors, here's some I ran into and any fixes I could find

Mineos

Does not work, will need a custom compose file for this (couldn't get it to work)

Pterodactyl

Does not work on RPI, there are some attemped ports, but I could get none of them to work

Proxmox

Proxmox flat out will not work unless you use pimox

NGINX Proxy Manager

If you want to use nginx proxy manager you will need a custom docker compose file. You can deploy this in yacht under the "projects" tab, or just straight from the command line by copying the file with the name docker-compose.yml and running sudo docker compose up -d, config is

version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'yobasystems/alpine-mariadb:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql
sudo apt -y update
#1. Install Micro
curl https://getmic.ro | bash
sudo mv micro /usr/bin
#2. Install Docker and Docker compose
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common
sudo apt install -y libffi-dev libssl-dev
sudo apt install -y python3-dev
sudo apt install -y python3-pip
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ${USER}
sudo pip3 install docker-compose
rm get-docker.sh
#3. Let people choose their container manager and set it up
echo "
Please select a Docker container manager:
Beginner: if you don't know much about docker or containers use CassaOS
Intermediate: if you know a bit about containers, but don't want the extra features of Portainer then use Yacht
Advanced: if you know a lot about containers, and also might want to use kubernetes install Portainer
"
PS3="Enter a number: "
select dockermanager in CassaOS Yacht Portainer
do
echo "
$dockermanager selected as container manager, installing
"
break
done
case $dockermanager in
"Yacht")
echo "Setting up Yacht"
# Setup Yacht if selected
docker volume create yacht
docker run -d --restart always -p 1234:8000 -v /var/run/docker.sock:/var/run/docker.sock -v yacht:/config --name yacht selfhostedpro/yacht
cat /etc/hosts | grep 127.0.1.1 | xargs -I {} python -c "print('{}'.split('\t')[1])" >> hostname.txt
HOSTNAME=$(<hostname.txt)
rm hostname.txt
# Enable yacht docker monitoring
echo " cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1" | sudo tee -a /boot/cmdline.txt
# Determine where yacht will be available
if [ -z "$HOSTNAME" ]
then
message=$(cat <<EOF
Unable to determine hostname, you can login (if on same network as pi) at one of the possible options:
eth0 (if on ethernet): http://$(hostname -I | awk '{print $1}'):1234
wlan0 (if on wifi): http://$(hostname -I | awk '{print $2}'):1234
EOF
)
else
message=$(cat <<EOF
You can login (if on same network as pi) at:
http://$HOSTNAME:1234
EOF
)
fi
# Print notice to user
echo "
======================================================
Yacht Login info
================
Default login info is:
email: admin@yacht.local
pw: pass
Make sure to change your admin info (login then click on email in top right and hit change password)
$message
If you are having problems connecting here are some troubleshooting suggestions:
ethernet: If connected with ethernet make sure you are on the same subnet
wifi: The pi supports 2.4Ghz and 5Ghz wifi, make sure the pi and your device are on the same frequency
Setting up apps with yacht
==========================
Yacht has tons of templates for various apps. Once logged in go to templates in the side menu bar and use:
Title: default
URL: https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/master/Template/yacht.json
If you have never used any of these services before I recommend setting up the templates and installing heimdall. It's a dashboard that will let you add your other apps. More details about templates here: https://github.com/SelfhostedPro/Yacht#templating
Monitoring with Yacht
=====================
Monitoring permissions for yacht have been configured but requires a reboot, so if you want to see information on the yacht dashboard then change your yacht password through a browser and run
sudo reboot now
Please read all of the above starting with Yacht Login info if it's your first time using yacht
"
;;
"CassaOS")
echo "Setting up CassaOS"
curl -fsSL https://get.casaos.io | bash
;;
"Portainer")
echo "Setting up Portainer"
mkdir portainer
mkdir portainer/data
# Creating docker compose file
echo "version: '3.3'
services:
portainer-ce:
ports:
- '9000:9000'
container_name: portainer
restart: always
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/home/pi/portainer/data:/data'
image: 'portainer/portainer-ce:latest'" > portainer/docker-compose.yml
cd portainer
sudo docker compose up -d
# Creating message for user to login
if [ -z "$HOSTNAME" ]
then
message=$(cat <<EOF
Unable to determine hostname, you can login (if on same network as pi) at one of the possible options:
eth0 (if on ethernet): http://$(hostname -I | awk '{print $1}'):9000
wlan0 (if on wifi): http://$(hostname -I | awk '{print $2}'):9000
EOF
)
else
message=$(cat <<EOF
You can login (if on same network as pi) at:
http://$HOSTNAME:9000
EOF
)
fi
echo "Portainer has been installed
$message
Details about using portainer can be found here: https://docs.portainer.io/start/install/server/setup
"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment